Skip to content
Snippets Groups Projects
Commit d2fcd71c authored by Carlos Vega's avatar Carlos Vega
Browse files

fixed tests for django

parent a9bc9156
No related branches found
No related tags found
1 merge request!279Bump requirements
Pipeline #34623 failed
......@@ -27,7 +27,8 @@ class StudySubjectAddFormTests(LoggedInWithWorkerTestCase):
'type': SUBJECT_TYPE_CHOICES_CONTROL,
'default_location': location.id,
'screening_number': "123",
'subject': self.subject.id
'subject': self.subject.id,
'postponed': False
}
def test_validation(self):
......
......@@ -26,7 +26,8 @@ class StudySubjectEditFormTests(LoggedInWithWorkerTestCase):
'screening_number': self.study_subject.screening_number,
'nd_number': self.study_subject.nd_number,
'subject': self.study_subject.subject.id,
'id': self.study_subject.id
'id': self.study_subject.id,
'postponed': False
}
def tearDown(self):
......
......@@ -15,8 +15,8 @@ class VisitAddFormTests(TestCase):
self.sample_data = {'datetime_begin': "2017-01-01",
'datetime_end': "2017-02-02",
'subject': self.subject.id,
'appointment_types': ''
'appointment_types': '',
'post_mail_sent': False
}
def test_validation(self):
......
......@@ -170,6 +170,14 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
self.worker.save()
form_data = self.create_add_form_data_for_study_subject()
form = SubjectAddForm(data=form_data, prefix="subject")
print(form.errors)
self.assertTrue(form.is_valid())
form = StudySubjectAddForm(data=form_data, prefix="study_subject", user=self.user, study=self.study)
print(form.errors)
self.assertTrue(form.is_valid())
form_data["study_subject-type"] = SUBJECT_TYPE_CHOICES_CONTROL
response = self.client.post(reverse('web.views.subject_add', kwargs={'study_id': self.study.id}),
data=form_data)
......@@ -191,6 +199,13 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
form_data["study_subject-type"] = SUBJECT_TYPE_CHOICES_CONTROL
form_data["study_subject-referral_letter"] = SimpleUploadedFile("file.txt", b"file_content")
form = SubjectAddForm(data=form_data, prefix="subject")
self.assertTrue(form.is_valid())
form = StudySubjectAddForm(data=form_data, prefix="study_subject", user=self.user, study=self.study)
self.assertTrue(form.is_valid())
response = self.client.post(reverse('web.views.subject_add', kwargs={'study_id': self.study.id}),
data=form_data)
self.assertEqual(response.status_code, 302)
......@@ -215,6 +230,7 @@ class SubjectsViewTests(LoggedInWithWorkerTestCase):
form_data["subject-sex"] = SEX_CHOICES_MALE
form_data["study_subject-type"] = SUBJECT_TYPE_CHOICES_PATIENT
form_data["study_subject-subject"] = self.study_subject.id
form_data["study_subject-postponed"] = False
# TODO remove after refactoring
form_data["study_subject-country"] = COUNTRY_AFGHANISTAN_ID
......
......@@ -4,7 +4,7 @@ import logging
from django.urls import reverse
from django.utils import timezone
from web.forms import VisitDetailForm
from web.forms import VisitDetailForm, VisitAddForm
from web.models import Visit, MailTemplate
from web.models.constants import MAIL_TEMPLATE_CONTEXT_VISIT
from web.tests import LoggedInTestCase
......@@ -82,6 +82,10 @@ class VisitViewTests(LoggedInTestCase):
form_data["datetime_begin"] = "2017-01-01"
form_data["datetime_end"] = "2017-04-01"
form_data["subject"] = subject.id
form_data["post_mail_sent"] = False
form = VisitAddForm(data=form_data)
self.assertTrue(form.is_valid())
response = self.client.post(reverse('web.views.visit_add', kwargs={'subject_id': subject.id}), data=form_data)
self.assertEqual(response.status_code, 302)
......
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