Skip to content

Commit

Permalink
Merge branch 'release/0.3.72' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Mar 26, 2024
2 parents b65c2aa + c9491b5 commit 07ad2c0
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 64 deletions.
4 changes: 4 additions & 0 deletions edc_crf/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import date

from django.db import models
from edc_consent.managers import ConsentObjectsByCdefManager, CurrentSiteByCdefManager
from edc_identifier.model_mixins import NonUniqueSubjectIdentifierFieldMixin
from edc_model.models import BaseUuidModel
from edc_registration.model_mixins import UpdatesOrCreatesRegistrationModelMixin
Expand Down Expand Up @@ -28,6 +29,9 @@ class SubjectConsent(


class SubjectConsentV1(SubjectConsent):
objects = ConsentObjectsByCdefManager()
on_site = CurrentSiteByCdefManager()

class Meta:
proxy = True

Expand Down
65 changes: 65 additions & 0 deletions edc_crf/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import sys
from pathlib import Path

from edc_test_settings.default_test_settings import DefaultTestSettings

app_name = "edc_crf"
base_dir = Path(__file__).parent.parent.parent
print(base_dir)

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
GIT_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=str(base_dir / "tests" / "etc"),
SILENCED_SYSTEM_CHECKS=[
"edc_consent.E001",
"edc_sites.E001",
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
],
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="visit_schedule_app.subjectvisitmissed",
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.staticfiles",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"multisite",
"edc_sites.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_consent.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_export.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_protocol.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"visit_schedule_app.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_crf.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
).settings


for k, v in project_settings.items():
setattr(sys.modules[__name__], k, v)
3 changes: 1 addition & 2 deletions edc_crf/tests/tests/test_crf_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
from edc_visit_schedule.site_visit_schedules import site_visit_schedules
from edc_visit_tracking.constants import SCHEDULED
from edc_visit_tracking.tests.helper import Helper
from visit_schedule_app.consents import consent_v1
from visit_schedule_app.models import SubjectVisit

from edc_crf.models import CrfStatus

from ..consents import consent_v1
from ..models import Crf
from ..visit_schedule import visit_schedule


@override_settings(
SUBJECT_CONSENT_MODEL="visit_schedule_app.subjectconsent",
SUBJECT_SCREENING_MODEL="visit_schedule_app.subjectscreening",
SITE_ID=10,
)
Expand Down
77 changes: 15 additions & 62 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,21 @@
#!/usr/bin/env python
import logging
from pathlib import Path
# -*- coding: utf-8 -*-
import os
import sys

from edc_test_utils import DefaultTestSettings, func_main
import django

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

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=str(base_dir / app_name / "tests" / "etc"),
SILENCED_SYSTEM_CHECKS=[
"edc_consent.E001",
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
],
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="visit_schedule_app.subjectvisitmissed",
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.staticfiles",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"multisite",
"edc_sites.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_consent.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_export.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_protocol.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"visit_schedule_app.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_crf.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
).settings


def main():
func_main(project_settings, f"{app_name}.tests")


if __name__ == "__main__":
logging.basicConfig()
main()
os.environ["DJANGO_SETTINGS_MODULE"] = f"{app_name}.tests.test_settings"
django.setup()
from django.test.runner import DiscoverRunner

tags = [t.split("=")[1] for t in sys.argv if t.startswith("--tag")]
failfast = any([True for t in sys.argv if t.startswith("--failfast")])
keepdb = any([True for t in sys.argv if t.startswith("--keepdb")])
skip_checks = any([True for t in sys.argv if t.startswith("--skip_checks")])
opts = dict(failfast=failfast, tags=tags, keepdb=keepdb, skip_checks=skip_checks)
failures = DiscoverRunner(**opts).run_tests([f"{app_name}.tests"], **opts)
sys.exit(failures)

0 comments on commit 07ad2c0

Please sign in to comment.