def test_wrong_value_set(self): field = fields.CharField("mother", 10) with self.assertRaises(exceptions.ValidationError): field.default = object with self.assertRaises(exceptions.ValidationError): field.default = 'abcdefghijklmnopqrstuvwxyz'
def test_right_value_length(self): fields.CharField('mother', max_length=10)
def test_max_length_sql_type(self): field = fields.CharField('mother', max_length=128) self.assertEquals(field.sql_type, 'Varchar(128)')
def test_correct_max_length_value(self): fields.CharField('value', 128)
def test_wrong_value_length(self): with self.assertRaises(exceptions.ValidationError): fields.CharField('mother', max_length=2)
def test_sql_type(self): field = fields.CharField('value') self.assertEquals(field.sql_type, 'Varchar(255)')
def test_wrong_max_length_values(self): for max_length in (object, -12, "128"): with self.assertRaises(exceptions.InitialError): fields.CharField('value', max_length=max_length)
def test_correct_value(self): fields.CharField('value')
def test_wrong_values(self): for value in (1, 12.32, object, True, []): with self.assertRaises(exceptions.ValidationError): fields.CharField(value)
class Person(table.Table): first_name = fields.CharField('John', 20) last_name = fields.CharField('Doe', 50) age = fields.IntegerField(18)
class Person(table.Table): first_name = fields.CharField('John') last_name = fields.CharField('Doe')
class Employee(Person): job = fields.CharField('Developer')