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

unit test and fix on rendering edit appointment

parent bb59a409
No related branches found
No related tags found
1 merge request!99separate patient data from study data
......@@ -42,7 +42,7 @@
<h3 class="box-title">Appointment's details</h3>
</div>
<div class="box-body">
{% for field in form %}
{% for field in appointment_form %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %} {% if field|is_checkbox %}multi-checkboxes{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
......@@ -87,6 +87,30 @@
</div><!-- /.box-body -->
</fieldset>
<fieldset>
<div class="box-header with-border">
<h3 class="box-title">Subject's study details</h3>
</div>
<div class="box-body">
{% for field in study_subject_form %}
<div class="col-md-6 form-group {% if field.errors %}has-error{% endif %}">
<label for="{# TODO #}" class="col-sm-4 control-label">
{{ field.label }}
</label>
<div class="col-sm-8">
{{ field|add_class:'form-control' }}
</div>
{% if field.errors %}
<span class="help-block"> {{ field.errors }} </span>
{% endif %}
</div>
{% endfor %}
</div><!-- /.box-body -->
</fieldset>
{% endif %}
<div class="box-footer">
<div class="col-sm-3">
......@@ -138,9 +162,10 @@
"autoWidth": false
});
});
appointment_type_behaviour($("input[name='appointment-appointment_types']"), $("input[name='appointment-length']"), "{% url 'web.api.appointment_types' %}");
var appointmentLengthInput = $("input[name='appointment-length']");
appointment_type_behaviour($("input[name='appointment-appointment_types']"), appointmentLengthInput, "{% url 'web.api.appointment_types' %}");
appointment_flying_team_place_behaviour($("select[name='appointment-flying_team']"), $("select[name='appointment-location']"));
appointment_date_change_behaviour($("input[name='appointment-datetime_when']"), $("select[name='appointment-worker_assigned']"), $("input[name='appointment-length']"), {{ appointment.id }});
appointment_date_change_behaviour($("input[name='appointment-datetime_when']"), $("select[name='appointment-worker_assigned']"), appointmentLengthInput, {{ appointment.id }});
</script>
......
......@@ -73,7 +73,7 @@ class TestApi(LoggedInWithWorkerTestCase):
result = availabilities(request)
entries = json.loads(result.content)['availabilities']
count = 0;
count = 0
for entry in entries:
count += len(entry["workers"])
self.assertTrue(count > 0)
import logging
from web.forms import StudySubjectAddForm
from web.forms import StudySubjectEditForm
from web.models import StudySubject
from web.models.constants import SUBJECT_TYPE_CHOICES_CONTROL
from web.tests import LoggedInWithWorkerTestCase
from web.tests.functions import create_subject, create_location, create_study_subject
from web.tests.functions import create_study_subject
logger = logging.getLogger(__name__)
......
......@@ -52,6 +52,24 @@ class AppointmentsViewTests(LoggedInTestCase):
reverse('web.views.appointment_edit', kwargs={'id': appointment.id}))
self.assertEqual(response.status_code, 200)
def test_render_appointments_edit(self):
appointment = create_appointment()
appointment.comment = "APPOINTMENT_COMMENT_DATA"
appointment.save()
appointment.visit.subject.comments = "STUDY_SUBJECT_COMMENT_DATA"
appointment.visit.subject.save()
appointment.visit.subject.subject.first_name = "SUBJECT_FIRST_NAME_DATA"
appointment.visit.subject.subject.save()
response = self.client.get(
reverse('web.views.appointment_edit', kwargs={'id': appointment.id}))
self.assertEqual(response.status_code, 200)
self.assertTrue(appointment.comment in response.content, msg="Appointment data not visible in rendered page")
self.assertTrue(appointment.visit.subject.comments in response.content,
msg="Subject study data not visible in rendered page")
self.assertTrue(appointment.visit.subject.subject.first_name in response.content,
msg="Subject data not visible in rendered page")
def test_save_appointments_edit_without_visit(self):
appointment = create_appointment()
appointment.visit = None
......
import datetime
from django.urls import reverse
from web.tests import LoggedInTestCase
......@@ -9,4 +7,3 @@ class ConfigurationViewTests(LoggedInTestCase):
def test_visit_details_request(self):
response = self.client.get(reverse('web.views.configuration'))
self.assertEqual(response.status_code, 200)
......@@ -117,7 +117,7 @@ def appointment_edit(request, id):
appointment_form = AppointmentEditForm(instance=the_appointment, user=request.user, prefix="appointment")
if the_appointment.visit is not None:
study_subject_form = StudySubjectEditForm(instance=the_appointment.visit.subject, prefix="subject")
study_subject_form = StudySubjectEditForm(instance=the_appointment.visit.subject, prefix="study-subject")
subject_form = SubjectEditForm(instance=the_appointment.visit.subject.subject,
prefix="subject")
contact_attempts = the_appointment.visit.subject.contactattempt_set.order_by('-datetime_when').all()
......
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