From ccef9140b2b090aa491ef7eac77d1c66afdc78c4 Mon Sep 17 00:00:00 2001 From: Carlos Vega <carlos.vega@uni.lu> Date: Thu, 18 Oct 2018 16:08:06 +0200 Subject: [PATCH] adapted some functions to be useful with the test_office_availability --- smash/web/tests/functions.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/smash/web/tests/functions.py b/smash/web/tests/functions.py index 0c2367ec..ce9fcc4b 100644 --- a/smash/web/tests/functions.py +++ b/smash/web/tests/functions.py @@ -154,13 +154,13 @@ def get_test_study(): return create_study("test-study") -def create_appointment_type(): +def create_appointment_type(code='C', default_duration=10, description='test'): return AppointmentType.objects.create( - code="C", - default_duration="10", - description="test", + code=code, + default_duration=default_duration, + description=description, ) - + def create_contact_attempt(subject=None, worker=None): if subject is None: @@ -264,11 +264,15 @@ def create_availability(worker=None, available_from=None, available_till=None, d return availability -def create_visit(subject=None): +def create_visit(subject=None, datetime_begin=None, datetime_end=None): if subject is None: subject = create_study_subject() - return Visit.objects.create(datetime_begin=get_today_midnight_date() + datetime.timedelta(days=-31), - datetime_end=get_today_midnight_date() + datetime.timedelta(days=31), + if datetime_begin is None: + datetime_begin = get_today_midnight_date() + datetime.timedelta(days=-31) + if datetime_end is None: + datetime_end = get_today_midnight_date() + datetime.timedelta(days=31) + return Visit.objects.create(datetime_begin=datetime_begin, + datetime_end=datetime_end, subject=subject, is_finished=False) -- GitLab