def test_pk():

    module = 'dmdj.tests'
    app_label = 'dmdj'
    bases = (Model,)
    model = make_model(model_json, bases, module, app_label)

    for table in model:
        if table.__name__ == 'TestTable1':
            assert table._meta.pk.name == 'pk'
def test_index():

    module = 'dmdj.tests'
    app_label = 'dmdj'
    bases = (Model,)
    model = make_model(model_json, bases, module, app_label)

    for table in model:
        if table.__name__ == 'TestTable2':
            for field in table._meta.fields:
                if field.name == 'string':
                    assert field.db_index
def test_foreign_key():

    module = 'dmdj.tests'
    app_label = 'dmdj'
    bases = (Model,)
    model = make_model(model_json, bases, module, app_label)

    for table in model:
        if table.__name__ == 'TestTable1':
            for field in table._meta.fields:
                if field.name == 'integer':
                    assert isinstance(field, ForeignKey)
                    assert field.to_fields[0] == 'integer'
                    assert field.related_query_name() == \
                        'test_table_1_integer_set'