forked from ambition-study/ambition-rando
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
62 lines (55 loc) · 1.95 KB
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
import django
import logging
import os
import sys
from django.conf import settings
from django.test.runner import DiscoverRunner
from edc_test_utils import DefaultTestSettings
from os.path import abspath, dirname, join
app_name = 'ambition_rando'
base_dir = dirname(abspath(__file__))
DEFAULT_SETTINGS = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=os.path.join(base_dir, app_name, "tests", "etc"),
SUBJECT_CONSENT_MODEL="ambition_subject.subjectconsent",
SUBJECT_VISIT_MODEL="ambition_subject.subjectvisit",
SUBJECT_REQUISITION_MODEL="ambition_subject.subjectrequisition",
EDC_RANDOMIZATION_LIST_MODEL="ambition_rando.randomizationlist",
EDC_RANDOMIZATION_LIST_FILE=join(
base_dir, app_name, "tests", "etc", "randomization_list.csv"),
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',
'django_revision.apps.AppConfig',
'edc_registration.apps.AppConfig',
'edc_device.apps.AppConfig',
'edc_identifier.apps.AppConfig',
'edc_protocol.apps.AppConfig',
"edc_randomization.apps.AppConfig",
"edc_sites.apps.AppConfig",
'ambition_rando.apps.EdcFacilityAppConfig',
'ambition_rando.apps.AppConfig',
],
add_dashboard_middleware=True,
add_lab_dashboard_middleware=True,
).settings
def main():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
tags = [t.split('=')[1] for t in sys.argv if t.startswith('--tag')]
failures = DiscoverRunner(failfast=True, tags=tags).run_tests(
[f'{app_name}.tests'])
sys.exit(failures)
if __name__ == "__main__":
logging.basicConfig()
main()