|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | import logging
|
3 |
| -import sys |
4 |
| -from os.path import abspath, dirname, join |
| 3 | +from pathlib import Path |
5 | 4 |
|
6 |
| -import django |
7 |
| -from django.conf import settings |
8 |
| -from django.test.runner import DiscoverRunner |
9 | 5 | from edc_constants.constants import IGNORE
|
10 |
| -from edc_test_utils import DefaultTestSettings |
| 6 | +from edc_test_utils import DefaultTestSettings, func_main |
11 | 7 |
|
12 |
| -base_dir = dirname(abspath(__file__)) |
13 | 8 | app_name = "edc_glucose"
|
14 | 9 |
|
15 |
| -DEFAULT_SETTINGS = DefaultTestSettings( |
| 10 | +base_dir = Path(__file__).absolute().parent |
| 11 | + |
| 12 | +project_settings = DefaultTestSettings( |
16 | 13 | calling_file=__file__,
|
17 | 14 | BASE_DIR=base_dir,
|
18 | 15 | APP_NAME=app_name,
|
19 |
| - ETC_DIR=join(base_dir, app_name, "tests", "etc"), |
20 |
| - # SUBJECT_SCREENING_MODEL=f"edc_screening.subjectscreening", |
21 |
| - # SUBJECT_CONSENT_MODEL=f"edc_metadata.subjectconsent", |
22 | 16 | SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
|
23 |
| - # SUBJECT_VISIT_MISSED_MODEL=f"edc_metadata.subjectvisitmissed", |
24 |
| - # SUBJECT_REQUISITION_MODEL=f"edc_metadata.subjectrequisition", |
25 | 17 | LIST_MODEL_APP_LABEL="edc_glucose",
|
26 | 18 | EDC_NAVBAR_VERIFY_ON_LOAD=IGNORE,
|
27 | 19 | EDC_AUTH_SKIP_SITE_AUTHS=True,
|
|
34 | 26 | ],
|
35 | 27 | EDC_DX_LABELS=dict(dm="Diabetes"),
|
36 | 28 | EDC_DX_REVIEW_LIST_MODEL_APP_LABEL="edc_glucose",
|
37 |
| - # INSTALLED_APPS=[ |
38 |
| - # "django.contrib.admin", |
39 |
| - # "django.contrib.auth", |
40 |
| - # "django.contrib.contenttypes", |
41 |
| - # "django.contrib.sessions", |
42 |
| - # "django.contrib.messages", |
43 |
| - # "django.contrib.staticfiles", |
44 |
| - # "django.contrib.sites", |
45 |
| - # "django_crypto_fields.apps.AppConfig", |
46 |
| - # "django_revision.apps.AppConfig", |
47 |
| - # "multisite", |
48 |
| - # "edc_appointment.apps.AppConfig", |
49 |
| - # "edc_action_item.apps.AppConfig", |
50 |
| - # "edc_crf.apps.AppConfig", |
51 |
| - # "edc_device.apps.AppConfig", |
52 |
| - # # "edc_dashboard.apps.AppConfig", |
53 |
| - # "edc_facility.apps.AppConfig", |
54 |
| - # "edc_lab.apps.AppConfig", |
55 |
| - # "edc_metadata.apps.AppConfig", |
56 |
| - # "edc_offstudy.apps.AppConfig", |
57 |
| - # "edc_registration.apps.AppConfig", |
58 |
| - # "edc_identifier.apps.AppConfig", |
59 |
| - # "edc_notification.apps.AppConfig", |
60 |
| - # "edc_sites.apps.AppConfig", |
61 |
| - # "edc_timepoint.apps.AppConfig", |
62 |
| - # "edc_visit_schedule.apps.AppConfig", |
63 |
| - # "edc_visit_tracking.apps.AppConfig", |
64 |
| - # "edc_glucose.apps.AppConfig", |
65 |
| - # ], |
66 |
| - RANDOMIZATION_LIST_PATH=join(base_dir, app_name, "tests", "test_randomization_list.csv"), |
67 | 29 | add_dashboard_middleware=True,
|
68 | 30 | add_lab_dashboard_middleware=True,
|
69 | 31 | use_test_urls=True,
|
70 | 32 | ).settings
|
71 | 33 |
|
72 | 34 |
|
73 | 35 | def main():
|
74 |
| - if not settings.configured: |
75 |
| - settings.configure(**DEFAULT_SETTINGS) |
76 |
| - django.setup() |
77 |
| - tags = [t.split("=")[1] for t in sys.argv if t.startswith("--tag")] |
78 |
| - failures = DiscoverRunner(failfast=False, tags=tags).run_tests([f"{app_name}.tests"]) |
79 |
| - sys.exit(failures) |
| 36 | + func_main(project_settings, *[f"{app_name}.tests"]) |
80 | 37 |
|
81 | 38 |
|
82 | 39 | if __name__ == "__main__":
|
|
0 commit comments