Skip to content

Commit

Permalink
Merge branch 'main' into cli
Browse files Browse the repository at this point in the history
* main:
  🧫 Pytest (#97)
  • Loading branch information
mrharpo committed Nov 6, 2023
2 parents 22b4bd3 + ab64591 commit 747781f
Show file tree
Hide file tree
Showing 8 changed files with 927 additions and 30 deletions.
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')
888 changes: 887 additions & 1 deletion pdm.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ dev = [
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",
"coverage>=7.3.2",
]

Expand Down

0 comments on commit 747781f

Please sign in to comment.