Skip to content
Snippets Groups Projects
Commit bed3e473 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit tests of redit appointment added

parent 99d288cf
No related branches found
No related tags found
1 merge request!39Subject additional fields added
Pipeline #
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment