Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Mar 27, 2024
1 parent a2ec092 commit f7a9c65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
29 changes: 25 additions & 4 deletions edc_metadata/tests/tests/test_persistant_singleton.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from copy import deepcopy
from datetime import datetime
from zoneinfo import ZoneInfo

import time_machine
from dateutil.relativedelta import relativedelta
from django import forms
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.test import TestCase, override_settings
from django.test import TestCase, override_settings, tag
from edc_appointment.constants import IN_PROGRESS_APPT, INCOMPLETE_APPT
from edc_appointment.models import Appointment
from edc_appointment.tests.test_case_mixins import AppointmentTestCaseMixin
from edc_constants.constants import FEMALE
from edc_consent import site_consents
from edc_consent.consent_definition import ConsentDefinition
from edc_constants.constants import FEMALE, MALE
from edc_facility import import_holidays
from edc_utils import get_utcnow
from edc_visit_schedule.constants import DAY1, MONTH1, MONTH3, MONTH6, WEEK2
Expand Down Expand Up @@ -109,16 +114,31 @@ def get_next_subject_visit(subject_visit):
return subject_visit


@time_machine.travel(datetime(2019, 6, 11, 8, 00, tzinfo=ZoneInfo("utc")))
@override_settings(
EDC_PROTOCOL_STUDY_OPEN_DATETIME=get_utcnow() - relativedelta(years=3),
EDC_PROTOCOL_STUDY_CLOSE_DATETIME=get_utcnow() + relativedelta(years=3),
EDC_PROTOCOL_STUDY_OPEN_DATETIME=datetime(2019, 6, 11, 8, 00, tzinfo=ZoneInfo("utc"))
- relativedelta(years=3),
EDC_PROTOCOL_STUDY_CLOSE_DATETIME=datetime(2019, 6, 11, 8, 00, tzinfo=ZoneInfo("utc"))
+ relativedelta(years=3),
)
class TestPersistantSingleton(TestCaseMixin, TestCase):
@classmethod
def setUpTestData(cls):
import_holidays()

def setUp(self):
consent_v1 = ConsentDefinition(
"edc_metadata.subjectconsentv1",
version="1",
start=get_utcnow() - relativedelta(years=3),
end=get_utcnow() + relativedelta(years=3),
age_min=18,
age_is_adult=18,
age_max=64,
gender=[MALE, FEMALE],
)
site_consents.registry = {}
site_consents.register(consent_v1)
site_visit_schedules._registry = {}
site_visit_schedules.loaded = False
site_visit_schedules.register(visit_schedule)
Expand Down Expand Up @@ -202,6 +222,7 @@ def test_baseline_not_required(self):
).exists()
)

@tag("1")
def test_1005_required(self):
site_metadata_rules.registry = {}
site_metadata_rules.register(self.rule_group)
Expand Down
3 changes: 1 addition & 2 deletions edc_metadata/tests/tests/test_requisition_rule_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.core.exceptions import ObjectDoesNotExist
from django.test import TestCase, tag
from django.test import TestCase
from edc_appointment.models import Appointment
from edc_consent import site_consents
from edc_constants.constants import FEMALE, MALE
Expand Down Expand Up @@ -190,7 +190,6 @@ def enroll(self, gender=None):
)
return subject_visit

@tag("1")
def test_rule_male(self):
subject_visit = self.enroll(gender=MALE)
rule_results, _ = MyRequisitionRuleGroup().evaluate_rules(related_visit=subject_visit)
Expand Down

0 comments on commit f7a9c65

Please sign in to comment.