Skip to content

Commit

Permalink
update visit schedule in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 17, 2024
1 parent 8cb0f36 commit 6e539f8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 10 deletions.
3 changes: 1 addition & 2 deletions edc_action_item/forms/action_item_form.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from django import forms
from django.apps import apps as django_apps
from edc_consent.modelform_mixins import RequiresConsentModelFormMixin
from edc_constants.constants import CANCELLED, NEW, OPEN
from edc_model_form.mixins import BaseModelFormMixin

from ..models import ActionItem


class ActionItemForm(RequiresConsentModelFormMixin, BaseModelFormMixin, forms.ModelForm):
class ActionItemForm(BaseModelFormMixin, forms.ModelForm):
subject_identifier = forms.CharField(
label="Subject Identifier",
required=False,
Expand Down
2 changes: 1 addition & 1 deletion edc_action_item/modelform_mixins/modelform_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def clean(self):
if self.action_cls:
try:
action_cls(
subject_identifier=self.subject_identifier,
subject_identifier=self.get_subject_identifier(),
action_identifier=self.action_identifier,
related_action_item=self.related_action_item,
readonly=True,
Expand Down
14 changes: 14 additions & 0 deletions edc_action_item/tests/consents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from edc_consent.consent_definition import ConsentDefinition
from edc_protocol import Protocol

consent_v1 = ConsentDefinition(
model="edc_action_item.subjectconsent",
start=Protocol().study_open_datetime,
end=Protocol().study_close_datetime,
gender=["M", "F"],
updates_versions=[],
version="1",
age_min=16,
age_max=64,
age_is_adult=18,
)
5 changes: 2 additions & 3 deletions edc_action_item/tests/test_case_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dateutil.relativedelta import relativedelta
from django.test import TestCase
from edc_consent import site_consents
from edc_consent.site_consents import site_consents
from edc_facility.import_holidays import import_holidays
from edc_registration.models import RegisteredSubject
from edc_utils import get_utcnow
Expand Down Expand Up @@ -34,8 +34,7 @@ def enroll(subject_identifier=None):
"edc_visit_schedule.onschedule"
)
schedule.put_on_schedule(
subject_identifier=subject_consent.subject_identifier,
onschedule_datetime=subject_consent.consent_datetime,
subject_consent.subject_identifier, subject_consent.consent_datetime
)
return subject_identifier

Expand Down
3 changes: 1 addition & 2 deletions edc_action_item/tests/tests/test_action_item.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dateutil.relativedelta import relativedelta
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.deletion import ProtectedError
from django.test import TestCase, tag
from django.test import TestCase
from edc_consent.tests.consent_test_utils import consent_definition_factory
from edc_constants.constants import CANCELLED, CLOSED, NEW, OPEN
from edc_utils import get_utcnow
Expand Down Expand Up @@ -85,7 +85,6 @@ def test_identifier_not_changed(self):
except ObjectDoesNotExist:
self.fail("ActionItem unexpectedly does not exist")

@tag("1")
def test_changes_action_item_status_from_new_to_open_on_edit(self):
action_type = ActionType.objects.get(name=FormZeroAction.name)

Expand Down
4 changes: 3 additions & 1 deletion edc_action_item/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, CrfCollection, Visit
from edc_visit_schedule.visit_schedule import VisitSchedule

from .consents import consent_v1

crfs = CrfCollection(
Crf(show_order=1, model="edc_action_item.crflongitudinalone", required=True),
Crf(show_order=2, model="edc_action_item.crflongitudinaltwo", required=True),
Expand Down Expand Up @@ -41,7 +43,7 @@
name="schedule",
onschedule_model="edc_visit_schedule.onschedule",
offschedule_model="edc_visit_schedule.offschedule",
consent_model="edc_action_item.subjectconsent",
consent_definitions=[consent_v1],
appointment_model="edc_appointment.appointment",
)

Expand Down
2 changes: 1 addition & 1 deletion edc_action_item/view_mixins/action_item_view_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def open_action_items(self) -> list[ActionItemModelWrapper]:
status__in=[NEW, OPEN],
site_id__in=sites.get_site_ids_for_user(request=self.request),
).order_by("-report_datetime")
return [self.action_item_model_wrapper_cls(model_obj=obj) for obj in qs]
return [self.action_item_model_wrapper_cls(model_obj=model_obj) for model_obj in qs]

0 comments on commit 6e539f8

Please sign in to comment.