From 034575f228b3cff413472f534ed9e7f645677e6a Mon Sep 17 00:00:00 2001 From: Jonathan Willitts Date: Tue, 21 Jan 2025 16:51:40 +0000 Subject: [PATCH] Refactor tests to use edc_test_settings.default_test_settings --- edc_qol/tests/test_settings.py | 59 ++++++++++++++++++++++++++++ runtests.py | 70 +--------------------------------- 2 files changed, 61 insertions(+), 68 deletions(-) create mode 100644 edc_qol/tests/test_settings.py diff --git a/edc_qol/tests/test_settings.py b/edc_qol/tests/test_settings.py new file mode 100644 index 0000000..573c83f --- /dev/null +++ b/edc_qol/tests/test_settings.py @@ -0,0 +1,59 @@ +import sys +from pathlib import Path + +from edc_test_settings.default_test_settings import DefaultTestSettings + +app_name = "edc_qol" +base_dir = Path(__file__).absolute().parent.parent.parent + +project_settings = DefaultTestSettings( + calling_file=__file__, + BASE_DIR=base_dir, + APP_NAME=app_name, + SILENCED_SYSTEM_CHECKS=[ + "sites.E101", + "edc_navbar.E003", + "edc_consent.E001", + "edc_sites.E001", + "edc_sites.E002", + ], + SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit", + EDC_AUTH_SKIP_SITE_AUTHS=True, + INSTALLED_APPS=[ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django.contrib.sites", + "multisite", + "django_crypto_fields.apps.AppConfig", + "django_revision.apps.AppConfig", + "edc_action_item.apps.AppConfig", + "edc_appointment.apps.AppConfig", + "edc_auth.apps.AppConfig", + "edc_dashboard.apps.AppConfig", + "edc_data_manager.apps.AppConfig", + "edc_facility.apps.AppConfig", + "edc_form_runners.apps.AppConfig", + "edc_lab.apps.AppConfig", + "edc_list_data.apps.AppConfig", + "edc_listboard.apps.AppConfig", + "edc_metadata.apps.AppConfig", + "edc_navbar.apps.AppConfig", + "edc_notification.apps.AppConfig", + "edc_registration.apps.AppConfig", + "edc_review_dashboard.apps.AppConfig", + "edc_sites.apps.AppConfig", + "edc_subject_dashboard.apps.AppConfig", + "edc_visit_schedule.apps.AppConfig", + "edc_visit_tracking.apps.AppConfig", + "edc_qol.apps.AppConfig", + "edc_appconfig.apps.AppConfig", + ], + add_dashboard_middleware=True, +).settings + +for k, v in project_settings.items(): + setattr(sys.modules[__name__], k, v) diff --git a/runtests.py b/runtests.py index 5614335..9834a70 100644 --- a/runtests.py +++ b/runtests.py @@ -1,71 +1,5 @@ #!/usr/bin/env python -import logging -from pathlib import Path - -from edc_test_utils import DefaultTestSettings, func_main - -app_name = "edc_qol" - -base_dir = Path(__file__).absolute().parent - -project_settings = DefaultTestSettings( - calling_file=__file__, - BASE_DIR=base_dir, - APP_NAME=app_name, - SILENCED_SYSTEM_CHECKS=[ - "sites.E101", - "edc_navbar.E002", - "edc_navbar.E003", - "edc_consent.E001", - "edc_sites.E001", - "edc_sites.E002", - ], - SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit", - ETC_DIR=str(base_dir / app_name / "tests" / "etc"), - EDC_AUTH_SKIP_SITE_AUTHS=True, - EDC_AUTH_SKIP_AUTH_UPDATER=True, - EDC_SITES_REGISTER_DEFAULT=True, - INSTALLED_APPS=[ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "django.contrib.sites", - "multisite", - "django_crypto_fields.apps.AppConfig", - "django_revision.apps.AppConfig", - "edc_action_item.apps.AppConfig", - "edc_appointment.apps.AppConfig", - "edc_auth.apps.AppConfig", - "edc_dashboard.apps.AppConfig", - "edc_data_manager.apps.AppConfig", - "edc_facility.apps.AppConfig", - "edc_form_runners.apps.AppConfig", - "edc_lab.apps.AppConfig", - "edc_list_data.apps.AppConfig", - "edc_listboard.apps.AppConfig", - "edc_metadata.apps.AppConfig", - "edc_navbar.apps.AppConfig", - "edc_notification.apps.AppConfig", - "edc_registration.apps.AppConfig", - "edc_review_dashboard.apps.AppConfig", - "edc_sites.apps.AppConfig", - "edc_subject_dashboard.apps.AppConfig", - "edc_visit_schedule.apps.AppConfig", - "edc_visit_tracking.apps.AppConfig", - "edc_qol.apps.AppConfig", - "edc_appconfig.apps.AppConfig", - ], - add_dashboard_middleware=True, -).settings - - -def main(): - func_main(project_settings, *[f"{app_name}.tests"]) - +from edc_test_settings.func_main import func_main2 if __name__ == "__main__": - logging.basicConfig() - main() + func_main2("edc_qol.tests.test_settings", "edc_qol.tests")