From bed3e47317137bf23bf3cef1ad9193326647b353 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 4 Apr 2017 17:17:16 +0200 Subject: [PATCH] unit tests of redit appointment added --- smash/web/tests/test_view_appointments.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/smash/web/tests/test_view_appointments.py b/smash/web/tests/test_view_appointments.py index 52c7e442..b29533c2 100644 --- a/smash/web/tests/test_view_appointments.py +++ b/smash/web/tests/test_view_appointments.py @@ -5,6 +5,7 @@ from django.urls import reverse from functions import create_subject, create_visit, create_appointment, create_worker from web.forms import AppointmentEditForm, SubjectEditForm from web.models import Appointment, Subject +from web.views.notifications import get_today_midnight_date from . import LoggedInTestCase @@ -69,3 +70,28 @@ class AppointmentsViewTests(LoggedInTestCase): reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data) self.assertEqual(response.status_code, 200) + + def test_save_appointments_edit(self): + subject = create_subject() + create_worker(self.user, True) + visit = create_visit(subject) + appointment = create_appointment(visit, get_today_midnight_date()) + + form_appointment = AppointmentEditForm(user=self.user, instance=appointment, prefix="appointment") + form_subject = SubjectEditForm(instance=subject, prefix="subject") + form_data = {} + for key, value in form_appointment.initial.items(): + if value is not None: + form_data['appointment-{}'.format(key)] = value + for key, value in form_subject.initial.items(): + if value is not None: + form_data['subject-{}'.format(key)] = value + form_data["appointment-status"] = Appointment.APPOINTMENT_STATUS_FINISHED + + response = self.client.post( + reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data) + + self.assertEqual(response.status_code, 302) + + updated_subject = Subject.objects.get(id=subject.id) + self.assertTrue(updated_subject.information_sent) \ No newline at end of file -- GitLab