Skip to content
Snippets Groups Projects

when appointment is finished, nd number for subject is required

Merged Piotr Gawron requested to merge 154-daily-planning into master
2 files
+ 34
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -3,12 +3,12 @@ import logging
from django.urls import reverse
from functions import create_subject, create_visit, create_appointment, create_worker, create_flying_team, \
from web.tests.functions import create_subject, create_visit, create_appointment, create_worker, create_flying_team, \
format_form_field
from web.forms import AppointmentEditForm, SubjectEditForm
from web.models import Appointment, Subject
from web.views.notifications import get_today_midnight_date
from . import LoggedInTestCase
from web.tests import LoggedInTestCase
logger = logging.getLogger(__name__)
@@ -84,19 +84,36 @@ class AppointmentsViewTests(LoggedInTestCase):
for key, value in form_appointment.initial.items():
if value is not None:
form_data['appointment-{}'.format(key)] = format_form_field(value)
form_data['appointment-status'.format(key)] = Appointment.APPOINTMENT_STATUS_FINISHED
form_data['appointment-status'] = Appointment.APPOINTMENT_STATUS_FINISHED
self.client.post(reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data)
appointment_result = Appointment.objects.filter(id=appointment.id)[0]
self.assertEqual(Appointment.APPOINTMENT_STATUS_FINISHED, appointment_result.status)
def test_save_appointments_edit(self):
def test_save_appointments_edit_with_invalid_nd_number(self):
subject = create_subject()
visit = create_visit(subject)
appointment = create_appointment(visit, get_today_midnight_date())
form_data = self.prepare_form(appointment, subject)
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, 200)
updated_subject = Subject.objects.get(id=subject.id)
self.assertFalse(updated_subject.information_sent)
def test_save_appointments_edit_with_valid_nd_number(self):
subject = create_subject()
visit = create_visit(subject)
appointment = create_appointment(visit, get_today_midnight_date())
form_data = self.prepare_form(appointment, subject)
form_data["appointment-status"] = Appointment.APPOINTMENT_STATUS_FINISHED
form_data["subject-nd_number"] = "ND9999"
response = self.client.post(
reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data)
@@ -127,9 +144,9 @@ class AppointmentsViewTests(LoggedInTestCase):
form_data["appointment-status"] = Appointment.APPOINTMENT_STATUS_FINISHED
form_data["appointment-flying_team"] = create_flying_team().id
form_data['appointment-status'] = Appointment.APPOINTMENT_STATUS_FINISHED
form_data["subject-nd_number"] = "ND9999"
response = self.client.post(
reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data)
self.client.post(reverse('web.views.appointment_edit', kwargs={'id': appointment.id}), data=form_data)
updated_subject = Subject.objects.get(id=subject.id)
self.assertIsNotNone(updated_subject.flying_team)
Loading