예제 #1
0
def cleanup(postgres_core: CoreCrudClient,
            postgres_transactions: TransactionsClient):
    yield
    collections = postgres_core.all_collections(request=MockStarletteRequest)
    for coll in collections:
        if coll.id.split("-")[0] == "test":
            # Delete the items
            items = postgres_core.item_collection(coll.id,
                                                  limit=100,
                                                  request=MockStarletteRequest)
            for feat in items.features:
                postgres_transactions.delete_item(feat.id,
                                                  request=MockStarletteRequest)

            # Delete the collection
            postgres_transactions.delete_collection(
                coll.id, request=MockStarletteRequest)
예제 #2
0
def test_delete_collection(
    postgres_core: CoreCrudClient,
    postgres_transactions: TransactionsClient,
    load_test_data: Callable,
):
    data = Collection.parse_obj(load_test_data("test_collection.json"))
    postgres_transactions.create_collection(data, request=MockStarletteRequest)

    deleted = postgres_transactions.delete_collection(
        data.id, request=MockStarletteRequest)

    with pytest.raises(NotFoundError):
        postgres_core.get_collection(deleted.id, request=MockStarletteRequest)