Skip to content

Commit

Permalink
Fix/update test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Nov 13, 2024
1 parent b8a6d7d commit 840af4a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 75 deletions.
69 changes: 69 additions & 0 deletions edc_pdf_reports/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import sys
from pathlib import Path

from edc_test_settings.default_test_settings import DefaultTestSettings

app_name = "edc_pdf_reports"
base_dir = Path(__file__).absolute().parent.parent.parent

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
EDC_AUTH_SKIP_SITE_AUTHS=True,
EDC_AUTH_SKIP_AUTH_UPDATER=True,
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"django_crypto_fields.apps.AppConfig",
"multisite",
"edc_auth.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_adverse_event.apps.AppConfig",
"adverse_event_app.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_lab_dashboard.apps.AppConfig",
"edc_label.apps.AppConfig",
"edc_locator.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_offstudy.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_prn.apps.AppConfig",
"edc_pdf_reports.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
add_lab_dashboard_middleware=True,
).settings


for k, v in project_settings.items():
setattr(sys.modules[__name__], k, v)
77 changes: 2 additions & 75 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,79 +1,6 @@
#!/usr/bin/env python
import logging
import os
import sys
from os.path import abspath, dirname

import django
from django.conf import settings
from django.test.runner import DiscoverRunner
from edc_test_utils import DefaultTestSettings

app_name = "edc_pdf_reports"
base_dir = dirname(abspath(__file__))

DEFAULT_SETTINGS = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
EDC_AUTH_SKIP_SITE_AUTHS=True,
EDC_AUTH_SKIP_AUTH_UPDATER=True,
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
ETC_DIR=os.path.join(base_dir, app_name, "tests", "etc"),
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"django_crypto_fields.apps.AppConfig",
"multisite",
"edc_action_item.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_label.apps.AppConfig",
"edc_locator.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_offstudy.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_prn.apps.AppConfig",
"edc_pdf_reports.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
add_lab_dashboard_middleware=True,
).settings


def main():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
failures = DiscoverRunner(failfast=True).run_tests([f"{app_name}.tests"])
sys.exit(failures)

from edc_test_settings.func_main import func_main2

if __name__ == "__main__":
logging.basicConfig()
main()
func_main2("edc_pdf_reports.tests.test_settings", "edc_pdf_reports.tests")

0 comments on commit 840af4a

Please sign in to comment.