示例#1
0
 def teardown():
     os.remove(blueprint_file)
     field = Fields.get(Fields.name == 'name')
     field.delete_instance()
     field = Fields.get(Fields.name == 'colour')
     field.delete_instance()
     type = Types.get(Types.name == 'flowers')
     type.delete_instance()
示例#2
0
def test_complex_blueprint(complex_blueprint, blueprint_file):
    """
    Tests the loading of blueprint with fields description.
    """
    load_blueprint(blueprint_file)
    type = Types.get(Types.name == 'plants')
    assert type.id > 0

    field = Fields.get(Fields.name == 'weight')
    assert field.field_type == 'int'
    assert field.type.id == type.id

    field = Fields.get(Fields.name == 'age')
    assert field.field_type == 'date'
    assert field.type.id == type.id

    field = Fields.get(Fields.name == 'colour')
    assert field.field_type == 'colours'
    assert field.type.id == type.id
示例#3
0
def test_load_simple_blueprint(simple_blueprint, blueprint_file):
    """
    Tests the loading of a simple blueprint that has only a list of fields.
    """
    load_blueprint(blueprint_file)
    type = Types.get(Types.name == 'flowers')
    assert type.id > 0
    assert type.enabled == True
    fields = ['name', 'colour']
    for field_name in fields:
        field = Fields.get(Fields.name == field_name)
        assert field.field_type == 'string'
        assert field.type.id == type.id
        assert field.nullable == True
示例#4
0
def test_nullable_blueprint(nullable_blueprint, blueprint_file):
    load_blueprint(blueprint_file)
    field = Fields.get(Fields.name == 'children')
    assert field.nullable == True
示例#5
0
 def teardown():
     field = Fields.get(Fields.name == 'children')
     field.delete_instance()