Exemple #1
0
def test_single_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][1]['data'][2][0] = 'Max'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)
def test_single_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][1]['data'][2][0] = 'Max'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)
Exemple #3
0
def test_multi_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][0]['schema']['foreignKeys'][0]['fields'] = ['name', 'surname']
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['fields'] = ['firstname', 'surname']
    descriptor['resources'][1]['data'][2][0] = 'Max'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)
def test_multi_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][0]['schema']['foreignKeys'][0]['fields'] = ['name', 'surname']
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['fields'] = ['firstname', 'surname']
    descriptor['resources'][1]['data'][2][0] = 'Max'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)
Exemple #5
0
def test_single_self_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][0]['schema']['foreignKeys'][0]['fields'] = 'parent_id'
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['resource'] = ''
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['fields'] = 'id'
    descriptor['resources'][0]['data'][2][0] = '0'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)
def test_single_self_field_foreign_key_invalid():
    descriptor = deepcopy(FK_DESCRIPTOR)
    descriptor['resources'][0]['schema']['foreignKeys'][0]['fields'] = 'parent_id'
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['resource'] = ''
    descriptor['resources'][0]['schema']['foreignKeys'][0]['reference']['fields'] = 'id'
    descriptor['resources'][0]['data'][2][0] = '0'
    resource = Package(descriptor).get_resource('main')
    with pytest.raises(exceptions.RelationError) as excinfo1:
        resource.read(relations=True)
    with pytest.raises(exceptions.RelationError) as excinfo2:
        resource.check_relations()
    assert 'Foreign key' in str(excinfo1.value)
    assert 'Foreign key' in str(excinfo2.value)