From 0237c3235db75df5b93af0ab904055402a6e2f19 Mon Sep 17 00:00:00 2001 From: Seamus Johnston Date: Wed, 7 Sep 2022 13:19:36 -0500 Subject: [PATCH] Add testing to the CI pipeline --- .github/workflows/test.yaml | 37 +++++++++++++++++++++++++++++++ docs/developer/README.md | 6 +++++ src/registrar/tests/__init__.py | 0 src/registrar/tests/common.py | 0 src/registrar/tests/test_views.py | 11 +++++++++ 5 files changed, 54 insertions(+) create mode 100644 src/registrar/tests/__init__.py create mode 100644 src/registrar/tests/common.py create mode 100644 src/registrar/tests/test_views.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bb1d55b91..eb1a5ff5f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,3 +33,40 @@ jobs: - name: Run bandit security scanning working-directory: ./src run: bandit -r . + + python-test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres + env: + POSTGRES_DB: app + POSTGRES_USER: user + POSTGRES_PASSWORD: feedabee + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + - name: Install Django + working-directory: ./src + run: | + python -m pip install --upgrade pip + pip install pipenv + pipenv install --system --dev + - name: Test + working-directory: ./src + env: + PYTHONUNBUFFERED: yup + DATABASE_URL: postgres://user:feedabee@localhost/app + DJANGO_SETTINGS_MODULE: registrar.config.settings + DJANGO_SECRET_KEY: feedabee + DJANGO_DEBUG: True + run: ./manage.py test diff --git a/docs/developer/README.md b/docs/developer/README.md index a35827fa7..8576306d3 100644 --- a/docs/developer/README.md +++ b/docs/developer/README.md @@ -50,6 +50,12 @@ Django's test suite: docker-compose exec app ./manage.py test ``` +OR + +```shell +docker-compose exec app python -Wa ./manage.py test # view deprecation warnings +``` + Linters: ```shell diff --git a/src/registrar/tests/__init__.py b/src/registrar/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/registrar/tests/common.py b/src/registrar/tests/common.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py new file mode 100644 index 000000000..f489ebe92 --- /dev/null +++ b/src/registrar/tests/test_views.py @@ -0,0 +1,11 @@ +from django.test import Client, TestCase + + +class HealthTest(TestCase): + def setUp(self): + self.client = Client() + + def test_health_check_endpoint(self): + response = self.client.get("/health/") + self.assertEqual(response.status_code, 200) + self.assertEqual(response.content, b"OK")