Esempio n. 1
0
def test_get_collection(
    postgres_core: CoreCrudClient,
    postgres_transactions: TransactionsClient,
    load_test_data: Callable,
):
    data = load_test_data("test_collection.json")
    postgres_transactions.create_collection(data, request=MockStarletteRequest)
    coll = postgres_core.get_collection(data["id"],
                                        request=MockStarletteRequest)
    assert Collection(**data).dict(exclude={"links"}) == Collection(
        **coll).dict(exclude={"links"})
    assert coll["id"] == data["id"]
def test_version_extension_collection():
    test_coll = request(VERSION_EXTENSION_COLLECTION)
    valid_coll = Collection(**test_coll).to_dict()
    dict_match(test_coll, valid_coll)
def test_item_assets_extension():
    test_coll = request(ITEM_ASSET_EXTENSION)
    valid_coll = Collection(**test_coll).to_dict()
    dict_match(test_coll, valid_coll)
Esempio n. 4
0
def test_commons_extension_validation_error():
    test_collection = request(COMMONS_EXTENSION)
    del test_collection["properties"]

    with pytest.raises(ValidationError):
        Collection(**test_collection)
Esempio n. 5
0
def test_assets_extension_validation_error():
    test_collection = request(ASSET_EXTENSION)
    del test_collection["assets"]

    with pytest.raises(ValidationError):
        Collection(**test_collection)
Esempio n. 6
0
def test_commons_extension_collection():
    test_coll = request(COMMONS_EXTENSION)
    valid_coll = Collection(**test_coll).to_dict()
    dict_match(test_coll, valid_coll)
Esempio n. 7
0
def test_collection_assets():
    test_coll = request(ASSET_EXTENSION)
    # The example is missing links
    test_coll["links"] = [{"href": "mocked", "rel": "items"}]
    valid_coll = Collection(**test_coll).to_dict()
    assert test_coll["assets"] == valid_coll["assets"]