Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧫 Pytest #97

Merged
merged 25 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ on: [push, pull_request, workflow_dispatch]

jobs:
tests:
name: ⚗️ Application Tests
name: ⚗️ App Tests
uses: WGBH-MLA/.github/.github/workflows/pytest-with-postgres.yml@main
secrets: inherit
with:
pdm_args: -G test,ci
pdm_args: -G test
pytest_args: -n auto --nbmake -ra -s
pg_db: ov-test

pg_db: ov
lint:
name: 👕 Lint
uses: WGBH-MLA/.github/.github/workflows/lint.yml@main
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/test-coverage.yml

This file was deleted.

8 changes: 8 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from os import environ as env

env['DJANGO_SETTINGS_MODULE'] = 'ov_wag.settings.test'
env['OV_DB_HOST'] = 'localhost'
env['OV_DB_PORT'] = '5432'
env['OV_DB_NAME'] = 'ov'
env['OV_DB_USER'] = 'postgres'
env['OV_DB_PASSWORD'] = 'postgres'
2 changes: 1 addition & 1 deletion ov_wag/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

DATABASES = {
'default': {
'ENGINE': os.environ.get('OV_DB_ENGINE'),
'ENGINE': os.environ.get('OV_DB_ENGINE', 'django.db.backends.postgresql'),
'HOST': os.environ.get('OV_DB_HOST'),
'PORT': os.environ.get('OV_DB_PORT'),
'NAME': os.environ.get('OV_DB_NAME'),
Expand Down
18 changes: 18 additions & 0 deletions ov_wag/settings/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from contextlib import suppress

from ov_wag.settings.base import * # noqa F403

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-qsu^g!8&aye$7b@ucxwa6!**1y@&1uwzcf+rs0832)t-yp7zsp'

# SECURITY WARNING: define the correct hosts in production!
ALLOWED_HOSTS = ['*']

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'


with suppress(ImportError):
from .local import * # noqa F403
6 changes: 6 additions & 0 deletions ov_wag/tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ def test_media_dir(self):
self.assertTrue(path.isdir(MEDIA_ROOT))

# Uncomment to show media directory in logs

def test_env(self):
"""Test if the environment variables are set"""
from os import environ as env

self.assertTrue(env.get('DJANGO_SETTINGS_MODULE') == 'ov_wag.settings.test')
1,064 changes: 1,062 additions & 2 deletions pdm.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ dev = [
'ruff~=0.1',
'pre-commit~=3.5',
]
test = [
"pytest>=7.4.3",
"pytest-django>=4.6.0",
"pytest-cov>=4.1.0",
"pytest-sugar>=0.9.7",
"pytest-xdist>=3.3.1",
"nbmake>=1.4.6",
]