Skip to content

Commit

Permalink
Use edc-appconfig, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Jan 26, 2024
1 parent 4e43625 commit 14668e4
Showing 1 changed file with 35 additions and 17 deletions.
52 changes: 35 additions & 17 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/usr/bin/env python
import logging
import os
import sys
from os.path import abspath, dirname
from pathlib import Path

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

app_name = "edc_vitals"
base_dir = dirname(abspath(__file__))
base_dir = Path(__file__).absolute().parent

DEFAULT_SETTINGS = DefaultTestSettings(
project_settings = DefaultTestSettings(
calling_file=__file__,
template_dirs=[os.path.join(base_dir, app_name, "tests", "templates")],
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=os.path.join(base_dir, app_name, "tests", "etc"),
ETC_DIR=str(base_dir / app_name / "tests" / "etc"),
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -26,20 +27,37 @@
"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_vitals.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
use_test_urls=True,
add_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=False, tags=tags).run_tests([f"{app_name}.tests"])
sys.exit(failures)
func_main(project_settings, f"{app_name}.tests")


if __name__ == "__main__":
Expand Down

0 comments on commit 14668e4

Please sign in to comment.