def test_index():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')
    tc.column('char', 'lname')
    tc.add_index(('fname', 'lname'), unique=True)

    assert tc.model._meta.indexes == [(('fname', 'lname'), True)]
Beispiel #2
0
def test_index():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')
    tc.column('char', 'lname')
    tc.add_index(('fname', 'lname'), unique=True)

    assert tc.model._meta.indexes == [(('fname', 'lname'), True)]
def test_constraint():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')

    const = peewee.SQL('fname not null')
    tc.add_constraint(const)

    assert tc.model._meta.constraints == [const]
Beispiel #4
0
def test_constraint():
    tc = TableCreator('awesome')
    tc.column('char', 'fname')

    const = peewee.SQL('fname not null')
    tc.add_constraint(const)

    assert tc.model._meta.constraints == [const]
def test_column():
    tc = TableCreator('awesome')
    tc.primary_key('id')
    tc.column('bare', 'col_bare')
    tc.column('biginteger', 'col_biginteger')
    tc.column('binary', 'col_binary')
    tc.column('blob', 'col_blob')
    tc.column('bool', 'col_bool')
    tc.column('char', 'col_char')
    tc.column('date', 'col_date')
    tc.column('datetime', 'col_datetime')
    tc.column('decimal', 'col_decimal')
    tc.column('double', 'col_double')
    tc.column('fixed', 'col_fixed')
    tc.column('float', 'col_float')
    tc.column('int', 'col_int')
    tc.column('integer', 'col_integer')
    tc.column('smallint', 'col_smallint')
    tc.column('smallinteger', 'col_smallinteger')
    tc.column('text', 'col_text')
    tc.column('time', 'col_time')
    tc.column('uuid', 'col_uuid')

    assert isinstance(tc.model.id, peewee.AutoField)
    assert isinstance(tc.model.col_bare, peewee.BareField)
    assert isinstance(tc.model.col_biginteger, peewee.BigIntegerField)
    assert isinstance(tc.model.col_binary, peewee.BlobField)
    assert isinstance(tc.model.col_blob, peewee.BlobField)
    assert isinstance(tc.model.col_bool, peewee.BooleanField)
    assert isinstance(tc.model.col_char, peewee.CharField)
    assert isinstance(tc.model.col_date, peewee.DateField)
    assert isinstance(tc.model.col_datetime, peewee.DateTimeField)
    assert isinstance(tc.model.col_decimal, peewee.DecimalField)
    assert isinstance(tc.model.col_double, peewee.DoubleField)
    assert isinstance(tc.model.col_fixed, peewee.CharField)
    assert isinstance(tc.model.col_float, peewee.FloatField)
    assert isinstance(tc.model.col_int, peewee.IntegerField)
    assert isinstance(tc.model.col_integer, peewee.IntegerField)
    assert isinstance(tc.model.col_smallint, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_smallinteger, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_text, peewee.TextField)
    assert isinstance(tc.model.col_time, peewee.TimeField)
    assert isinstance(tc.model.col_uuid, peewee.UUIDField)
Beispiel #6
0
def test_column():
    tc = TableCreator('awesome')
    tc.primary_key('id')
    tc.column('bare', 'col_bare')
    tc.column('biginteger', 'col_biginteger')
    tc.column('binary', 'col_binary')
    tc.column('blob', 'col_blob')
    tc.column('bool', 'col_bool')
    tc.column('char', 'col_char')
    tc.column('date', 'col_date')
    tc.column('datetime', 'col_datetime')
    tc.column('decimal', 'col_decimal')
    tc.column('double', 'col_double')
    tc.column('fixed', 'col_fixed')
    tc.column('float', 'col_float')
    tc.column('int', 'col_int')
    tc.column('integer', 'col_integer')
    tc.column('smallint', 'col_smallint')
    tc.column('smallinteger', 'col_smallinteger')
    tc.column('text', 'col_text')
    tc.column('time', 'col_time')
    tc.column('uuid', 'col_uuid')

    assert isinstance(tc.model.id, peewee.AutoField)
    assert isinstance(tc.model.col_bare, peewee.BareField)
    assert isinstance(tc.model.col_biginteger, peewee.BigIntegerField)
    assert isinstance(tc.model.col_binary, peewee.BlobField)
    assert isinstance(tc.model.col_blob, peewee.BlobField)
    assert isinstance(tc.model.col_bool, peewee.BooleanField)
    assert isinstance(tc.model.col_char, peewee.CharField)
    assert isinstance(tc.model.col_date, peewee.DateField)
    assert isinstance(tc.model.col_datetime, peewee.DateTimeField)
    assert isinstance(tc.model.col_decimal, peewee.DecimalField)
    assert isinstance(tc.model.col_double, peewee.DoubleField)
    assert isinstance(tc.model.col_fixed, peewee.CharField)
    assert isinstance(tc.model.col_float, peewee.FloatField)
    assert isinstance(tc.model.col_int, peewee.IntegerField)
    assert isinstance(tc.model.col_integer, peewee.IntegerField)
    assert isinstance(tc.model.col_smallint, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_smallinteger, peewee.SmallIntegerField)
    assert isinstance(tc.model.col_text, peewee.TextField)
    assert isinstance(tc.model.col_time, peewee.TimeField)
    assert isinstance(tc.model.col_uuid, peewee.UUIDField)