Пример #1
0
 def testMatchWithUmlaut(self):
     fieldFormat = fields.ChoiceFieldFormat("geschlecht", False, None,
                                            u"\"männlich\", \"weiblich\"",
                                            _anyFormat)
     self.assertEquals(fieldFormat.validated(u"männlich"), u"männlich")
     self.assertRaises(fields.FieldValueError, fieldFormat.validated,
                       u"unbekannt")
Пример #2
0
 def testMatchingChoice(self):
     fieldFormat = fields.ChoiceFieldFormat("color", False, None,
                                            "red,grEEn, blue ", _anyFormat)
     self.assertEquals(fieldFormat.validated("red"), "red")
     # Value without blanks around it.
     self.assertEquals(fieldFormat.validated("grEEn"), "grEEn")
     # Value with blanks around it.
     self.assertEquals(fieldFormat.validated("blue"), "blue")
     # Disregard upper/lower case.
     self.assertRaises(fields.FieldValueError, fieldFormat.validated,
                       "gReen")
     self.assertRaises(fields.FieldValueError, fieldFormat.validated, "")
Пример #3
0
 def testPossiblyEmptyFieldWithLength(self):
     fieldFormat = fields.ChoiceFieldFormat("optional_color", True, ":5",
                                            "red, green, blue", _anyFormat)
     self.assertEquals(fieldFormat.validated("red"), "red")
     self.assertEquals(fieldFormat.validated(""), "")
Пример #4
0
 def testMatchingOnlyChoice(self):
     fieldFormat = fields.ChoiceFieldFormat("color", False, None, "red",
                                            _anyFormat)
     self.assertEquals(fieldFormat.validated("red"), "red")
Пример #5
0
 def testImproperChoice(self):
     fieldFormat = fields.ChoiceFieldFormat("color", False, None,
                                            "red,green, blue ", _anyFormat)
     self.assertRaises(fields.FieldValueError, fieldFormat.validated,
                       "tree")