def test_non_ascii_chars(self): value = u'тест' field = StringField() value_to_db = field.to_db(value) value_to_python = field.to_python(value_to_db) self.assertIsInstance(value_to_db, str) self.assertIsInstance(value_to_python, unicode) self.assertEqual(value_to_python, value)
def test_non_ascii_chars(self): value = u"тест" field = StringField() value_to_db = field.to_db(value) value_to_python = field.to_python(value_to_db) self.assertIsInstance(value_to_db, str) self.assertIsInstance(value_to_python, unicode) self.assertEqual(value_to_python, value)
def test_fail_on_regex(self): value = u"123test45" field = StringField(regex=u"^\d+$") with self.assertRaises(ValidationError): field.validate(value)
def test_fail_on_max_length(self): value = u"test" field = StringField(max_length=1) with self.assertRaises(ValidationError): field.validate(value)
def test_fail_on_invalid_type(self): value = {} field = StringField() with self.assertRaises(ValidationError): field.validate(value)
class Record(Model): pk = Num64Field(min_value=0) data = StringField(min_length=1, max_length=100)
def test_fail_on_regex(self): value = u'123test45' field = StringField(regex=u'^\d+$') with self.assertRaises(ValidationError): field.validate(value)
def test_fail_on_max_length(self): value = u'test' field = StringField(max_length=1) with self.assertRaises(ValidationError): field.validate(value)
class Record(Model): pk = Num64Field() data = StringField()
class Record(Model): pk = Num64Field(default=get_default_pk) data = StringField(default=DataGetter())
class Record(Model): pk = Num64Field(default=default_pk) data = StringField(default=default_data)