Esempio n. 1
0
 def test_not_born_yet(self):
     tomorrow = (now() + timedelta(hours=24)).date()
     citizen = CitizenFactory(birth_date=tomorrow)
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn('birth_date', form.errors)
Esempio n. 2
0
 def test_not_born_yet(self):
     tomorrow = (now() + timedelta(hours=24)).date()
     citizen = CitizenFactory(birth_date=tomorrow)
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn('birth_date', form.errors)
Esempio n. 3
0
 def test_wrong_gender_for_national_id(self):
     citizen = CitizenFactory(
         gender=FEMALE,
         national_id=123456789012,  # expecting male gender
     )
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn("does not match gender", str(form.errors))
Esempio n. 4
0
 def test_wrong_gender_for_national_id(self):
     citizen = CitizenFactory(
         gender=FEMALE,
         national_id=123456789012,  # expecting male gender
     )
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertFalse(form.is_valid())
     self.assertIn("does not match gender", str(form.errors))
Esempio n. 5
0
def line_to_dictionary(line):
    """
    Given a VALUES line from the input, return a dictionary
    with all the field values, nicely cleaned up and converted
    to the right data types.
    :param line: A VALUES line from the input
    :raises ValueError: if any inputs are not valie
    :return: a dictionary
    """
    data = dict(zip(FIELD_NAMES, break_line(line)))
    form = CitizenRecordForm(data=data)
    if not form.is_valid():
        raise ValueError(form.errors)
    return form.cleaned_data
Esempio n. 6
0
def line_to_dictionary(line):
    """
    Given a VALUES line from the input, return a dictionary
    with all the field values, nicely cleaned up and converted
    to the right data types.
    :param line: A VALUES line from the input
    :raises ValueError: if any inputs are not valie
    :return: a dictionary
    """
    data = dict(zip(FIELD_NAMES, break_line(line)))
    form = CitizenRecordForm(data=data)
    if not form.is_valid():
        raise ValueError(form.errors)
    return form.cleaned_data
Esempio n. 7
0
 def test_simple(self):
     citizen = CitizenFactory()
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertTrue(form.is_valid(), msg="Form errors: %r" % form.errors)
Esempio n. 8
0
 def test_simple(self):
     citizen = CitizenFactory()
     data = model_to_dict(citizen)
     data = stringize(data)
     form = CitizenRecordForm(data)
     self.assertTrue(form.is_valid(), msg="Form errors: %r" % form.errors)