mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-28 15:10:34 +02:00
Merge pull request #104 from cisagov/sspj/django-tests
Add testing to the CI pipeline
This commit is contained in:
commit
d2da8d1d8f
5 changed files with 54 additions and 0 deletions
37
.github/workflows/test.yaml
vendored
37
.github/workflows/test.yaml
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
0
src/registrar/tests/__init__.py
Normal file
0
src/registrar/tests/__init__.py
Normal file
0
src/registrar/tests/common.py
Normal file
0
src/registrar/tests/common.py
Normal file
11
src/registrar/tests/test_views.py
Normal file
11
src/registrar/tests/test_views.py
Normal file
|
@ -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")
|
Loading…
Add table
Add a link
Reference in a new issue