Example #1
0
 def test_can_accept_value_matching_pattern(self):
     field_format = fields.PatternFieldFormat("x", False, None, "h*g?", _ANY_FORMAT)
     self.assertEqual(field_format.validated("hgo"), "hgo")
     self.assertEqual(field_format.validated("hugo"), "hugo")
     self.assertEqual(field_format.validated("huuuuga"), "huuuuga")
Example #2
0
 def test_fails_on_value_not_matching_pattern(self):
     field_format = fields.PatternFieldFormat("x", False, None, "h*g?", _ANY_FORMAT)
     self.assertRaises(errors.FieldValueError, field_format.validated, "")
     self.assertRaises(errors.FieldValueError, field_format.validated, "hang")
Example #3
0
 def test_can_output_sql_without_range(self):
     field_format = fields.PatternFieldFormat("x", False, None, "h*g?",
                                              _ANY_FORMAT)
     column_def, constraint = field_format.as_sql(sql.MSSQL)
     self.assertEqual(column_def, "x varchar(255) not null")
     self.assertEqual(constraint, "")