Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 18, 2024
1 parent 255298c commit e913f47
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
16 changes: 16 additions & 0 deletions edc_pharmacy/tests/consents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from edc_consent.consent_definition import ConsentDefinition
from edc_consent.site_consents import site_consents
from edc_constants.constants import FEMALE, MALE
from edc_protocol import Protocol

v1_consent = ConsentDefinition(
"edc_pharmacy.subjectconsent",
version="1",
start=Protocol().study_open_datetime,
end=Protocol().study_close_datetime,
age_min=18,
age_is_adult=18,
age_max=64,
gender=[MALE, FEMALE],
)
site_consents.register(v1_consent)
28 changes: 20 additions & 8 deletions edc_pharmacy/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from datetime import date

from django.db import models
from edc_crf.model_mixins import CrfModelMixin
from edc_identifier.managers import SubjectIdentifierManager
from edc_identifier.model_mixins import NonUniqueSubjectIdentifierFieldMixin
from edc_model.models import BaseUuidModel
from edc_registration.model_mixins import UpdatesOrCreatesRegistrationModelMixin
from edc_screening.model_mixins import ScreeningModelMixin
from edc_sites.model_mixins import SiteModelMixin
from edc_utils import get_utcnow
Expand All @@ -11,19 +15,27 @@
from edc_pharmacy.model_mixins import StudyMedicationCrfModelMixin


class SubjectScreening(ScreeningModelMixin, BaseUuidModel):
objects = SubjectIdentifierManager()
class SubjectConsent(
SiteModelMixin,
NonUniqueSubjectIdentifierFieldMixin,
UpdatesOrCreatesRegistrationModelMixin,
BaseUuidModel,
):
report_datetime = models.DateTimeField(default=get_utcnow)

consent_datetime = models.DateTimeField(default=get_utcnow)

class SubjectConsent(SiteModelMixin, BaseUuidModel):
subject_identifier = models.CharField(max_length=25)
version = models.CharField(max_length=25, default="1")

consent_datetime = models.DateTimeField()
identity = models.CharField(max_length=25)

dob = models.DateTimeField(null=True)
confirm_identity = models.CharField(max_length=25)

class Meta:
pass
dob = models.DateField(default=date(1995, 1, 1))


class SubjectScreening(ScreeningModelMixin, BaseUuidModel):
objects = SubjectIdentifierManager()


class SubjectVisit(SiteModelMixin, VisitModelMixin, BaseUuidModel):
Expand Down
12 changes: 0 additions & 12 deletions edc_pharmacy/tests/tests/test_study_medication_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from edc_appointment.models import Appointment
from edc_appointment.tests.helper import Helper
from edc_appointment.utils import get_next_appointment
from edc_consent.site_consents import (
AlreadyRegistered as ConsentDefinitionAlreadyRegistered,
)
from edc_consent.tests.consent_test_utils import consent_definition_factory
from edc_constants.constants import YES
from edc_facility import import_holidays
from edc_protocol import Protocol
Expand Down Expand Up @@ -51,14 +47,7 @@ def setUpTestData(cls):
def setUp(self) -> None:
site_visit_schedules._registry = {}
site_visit_schedules.loaded = False

site_visit_schedules.register(visit_schedule)
for schedule in visit_schedule.schedules.values():
try:
consent_definition_factory(model=schedule.consent_model)
except ConsentDefinitionAlreadyRegistered:
pass

self.subject_identifier = "12345"
self.registration_datetime = get_utcnow() - relativedelta(years=5)
RegisteredSubject.objects.create(
Expand All @@ -71,7 +60,6 @@ def setUp(self) -> None:
now=get_utcnow() - relativedelta(years=5),
)
self.helper.consent_and_put_on_schedule(
subject_identifier=self.subject_identifier,
visit_schedule_name="visit_schedule",
schedule_name="schedule",
)
Expand Down
9 changes: 5 additions & 4 deletions edc_pharmacy/tests/visit_schedule.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from dateutil.relativedelta import relativedelta
from edc_consent.utils import get_consent_model_name
from edc_visit_schedule.schedule import Schedule
from edc_visit_schedule.visit import Crf, FormsCollection, Visit
from edc_visit_schedule.visit import Crf, CrfCollection, Visit
from edc_visit_schedule.visit_schedule import VisitSchedule

from edc_pharmacy.tests.consents import v1_consent

app_label = "edc_pharmacy"

crfs = FormsCollection(
crfs = CrfCollection(
Crf(show_order=1, model=f"{app_label}.studymedication", required=True),
)

Expand Down Expand Up @@ -49,7 +50,7 @@
name="schedule",
onschedule_model="edc_pharmacy.onschedule",
offschedule_model="edc_pharmacy.offschedule",
consent_model=get_consent_model_name(),
consent_definitions=[v1_consent],
appointment_model="edc_appointment.appointment",
)

Expand Down

0 comments on commit e913f47

Please sign in to comment.