Skip to content

Commit

Permalink
Merge branch 'release/0.3.43' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 24, 2024
2 parents 7bcaeef + 5806deb commit 541a9a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 0 additions & 2 deletions edc_offstudy/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from edc_action_item.models import ActionNoManagersModelMixin
from edc_consent.model_mixins import RequiresConsentFieldsModelMixin
from edc_identifier.managers import SubjectIdentifierManager
from edc_model.models import BaseUuidModel, HistoricalRecords
from edc_sites.managers import CurrentSiteManager
Expand All @@ -10,7 +9,6 @@


class SubjectOffstudy(
RequiresConsentFieldsModelMixin,
OffstudyModelMixin,
SiteModelMixin,
ActionNoManagersModelMixin,
Expand Down
5 changes: 4 additions & 1 deletion edc_offstudy/tests/consents.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from edc_consent import site_consents
from edc_consent.consent_definition import ConsentDefinition
from edc_constants.constants import FEMALE, MALE
from edc_protocol import Protocol

v1_consent = ConsentDefinition(
consent_v1 = ConsentDefinition(
"edc_offstudy.subjectconsent",
version="1",
start=Protocol().study_open_datetime,
Expand All @@ -12,3 +13,5 @@
age_max=64,
gender=[MALE, FEMALE],
)

site_consents.register(consent_v1)
11 changes: 8 additions & 3 deletions edc_offstudy/tests/tests/test_offstudy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from dateutil.relativedelta import relativedelta
from django.conf import settings
from django.contrib.sites.models import Site
from django.test import TestCase, override_settings
from edc_action_item import site_action_items
from edc_appointment.constants import INCOMPLETE_APPT
from edc_appointment.models import Appointment
from edc_consent import site_consents
from edc_constants.constants import DEAD
from edc_facility.import_holidays import import_holidays
from edc_utils import get_dob, get_utcnow
Expand All @@ -16,7 +17,6 @@
from edc_offstudy.utils import OffstudyError

from ...action_items import EndOfStudyAction
from ..consents import v1_consent
from ..forms import CrfOneForm, NonCrfOneForm, SubjectOffstudyForm
from ..models import CrfOne, NonCrfOne, OffScheduleOne, SubjectConsent
from ..visit_schedule import visit_schedule1
Expand All @@ -32,7 +32,6 @@ def setUpClass(cls):
super().setUpClass()
site_visit_schedules._registry = {}
site_visit_schedules.register(visit_schedule1)
site_consents.register(v1_consent)
site_action_items.register(EndOfStudyAction)

def setUp(self):
Expand Down Expand Up @@ -261,6 +260,7 @@ def test_modelform_mixin_ok(self):
subject_identifier=self.subject_identifier,
offstudy_datetime=get_utcnow(),
offstudy_reason=DEAD,
site=Site.objects.get(id=settings.SITE_ID).id,
)
# take off schedule1
OffScheduleOne.objects.create(
Expand All @@ -277,6 +277,7 @@ def test_offstudy_modelform(self):
subject_identifier=self.subject_identifier,
offstudy_datetime=get_utcnow(),
offstudy_reason=DEAD,
site=Site.objects.get(id=settings.SITE_ID).id,
)
form = SubjectOffstudyForm(data=data)
self.assertFalse(form.is_valid())
Expand Down Expand Up @@ -310,6 +311,7 @@ def test_crf_modelform_ok(self):
report_datetime=appointments[0].appt_datetime,
visit_schedule_name=appointments[0].visit_schedule_name,
schedule_name=appointments[0].schedule_name,
site=Site.objects.get(id=settings.SITE_ID).id,
)
form = CrfOneForm(data=data)
form.is_valid()
Expand All @@ -335,6 +337,7 @@ def test_crf_modelform_ok(self):
report_datetime=appointments[0].appt_datetime + relativedelta(days=2),
visit_schedule_name="visit_schedule1",
schedule_name="schedule1",
site=Site.objects.get(id=settings.SITE_ID).id,
)
form = CrfOneForm(data=data)
self.assertFalse(form.is_valid())
Expand All @@ -345,6 +348,7 @@ def test_non_crf_modelform1(self):
data = dict(
subject_identifier=self.subject_identifier,
report_datetime=self.consent_datetime,
site=Site.objects.get(id=settings.SITE_ID).id,
)
form = NonCrfOneForm(data=data)
form.is_valid()
Expand All @@ -355,6 +359,7 @@ def test_non_crf_modelform2(self):
data = dict(
subject_identifier=self.subject_identifier,
report_datetime=self.consent_datetime,
site=Site.objects.get(id=settings.SITE_ID).id,
)

# take off schedule1 and hour after trying to submit CRF
Expand Down
4 changes: 3 additions & 1 deletion edc_offstudy/tests/visit_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from edc_visit_schedule.visit import Crf, FormsCollection, Visit
from edc_visit_schedule.visit_schedule import VisitSchedule

from edc_offstudy.tests.consents import consent_v1

crfs = FormsCollection(
Crf(show_order=1, model="edc_offstudy.crfone", required=True),
)
Expand All @@ -19,7 +21,7 @@
name="schedule1",
onschedule_model="edc_offstudy.onscheduleone",
offschedule_model="edc_offstudy.offscheduleone",
consent_model="edc_offstudy.subjectconsent",
consent_definitions=[consent_v1],
appointment_model="edc_appointment.appointment",
)

Expand Down

0 comments on commit 541a9a9

Please sign in to comment.