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

unit test for checking if nd number validation works

parent a107e459
No related branches found
No related tags found
1 merge request!101Resolve "list of subjects should contain columns dependent on the study"
import logging
import re
from django import forms
......@@ -7,6 +8,8 @@ from web.forms.forms import DATETIMEPICKER_DATE_ATTRS, get_worker_from_args
from web.models import StudySubject, Study, StudyColumns
from web.models.constants import SCREENING_NUMBER_PREFIXES_FOR_TYPE
logger = logging.getLogger(__name__)
class StudySubjectAddForm(ModelForm):
datetime_contact_reminder = forms.DateTimeField(label="Contact on",
......
......@@ -30,9 +30,14 @@ class StudySubjectAddFormTests(LoggedInWithWorkerTestCase):
def test_validation_for_study_without_columns(self):
form = StudySubjectAddForm(data=self.sample_data, user=self.user, study=create_empty_study())
form.is_valid()
self.assertTrue(form.is_valid())
def test_validate_nd_number(self):
self.sample_data['nd_number'] = 'invalid nd number'
form = StudySubjectAddForm(data=self.sample_data, user=self.user, study=self.study)
self.assertFalse(form.is_valid())
self.assertTrue("nd_number" in form.errors)
def test_invalid(self):
form_data = self.sample_data
form_data['screening_number'] = "123"
......
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