Skip to content

Commit

Permalink
Delete resources after tests
Browse files Browse the repository at this point in the history
Remove GWC layers and workspace after testing so the tests can be run idempotently
  • Loading branch information
vuilleumierc authored and groldan committed Oct 8, 2024
1 parent 01de786 commit 3c4f46d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
26 changes: 11 additions & 15 deletions acceptance_tests/tests/test_cascaded_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,13 @@ def create_cascaded_wms_store_payload():
}


def delete_wms_store(geoserver):
geoserver.delete_request(
f"/rest/workspaces/{WORKSPACE}/wmsstores/{WMS_STORE}?recurse=true"
)


def delete_wmts_store(geoserver):
geoserver.delete_request(
f"/rest/workspaces/{WORKSPACE}/wmtsstores/{WMTS_STORE}?recurse=true"
)


@pytest.fixture(scope="module")
def geoserver():
geoserver = GeoServerCloud(url=GEOSERVER_URL)
geoserver.create_workspace(WORKSPACE, set_default_workspace=True)
geoserver.publish_workspace(WORKSPACE)
yield geoserver
# geoserver.delete_workspace(WORKSPACE)
geoserver.delete_workspace(WORKSPACE)


def test_cascaded_wms(geoserver):
Expand Down Expand Up @@ -98,7 +86,11 @@ def test_cascaded_wms(geoserver):
data = json.loads(response.read().decode("utf-8"))
assert data.get("features") == []

delete_wms_store(geoserver)
# Delete store
response = geoserver.delete_request(
f"/rest/workspaces/{WORKSPACE}/wmsstores/{WMS_STORE}?recurse=true"
)
assert response.status_code == 200


def test_cascaded_wmts(geoserver):
Expand Down Expand Up @@ -135,6 +127,10 @@ def test_cascaded_wmts(geoserver):
)
assert response.info().get("Content-Type") == format

# Delete layer and store
response = geoserver.delete_request(f"/gwc/rest/layers/{WORKSPACE}:{WMTS_LAYER}")
assert response.status_code == 200
delete_wmts_store(geoserver)
response = geoserver.delete_request(
f"/rest/workspaces/{WORKSPACE}/wmtsstores/{WMTS_STORE}?recurse=true"
)
assert response.status_code == 200
4 changes: 2 additions & 2 deletions acceptance_tests/tests/test_gwc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def geoserver_with_gwc_layers(geoserver):
geoserver.get_request(
f"/rest/workspaces/{WORKSPACE}/wmtsstores/{WMTS_STORE}/layers/{WMTS_LAYER}.json"
)
response = geoserver.publish_gwc_layer(WORKSPACE, WMTS_LAYER)
assert response.status_code == 200
geoserver.publish_gwc_layer(WORKSPACE, WMTS_LAYER)
yield geoserver
geoserver.delete_request(f"/gwc/rest/layers/{WORKSPACE}:{WMTS_LAYER}")
geoserver.delete_workspace(WORKSPACE)


Expand Down

0 comments on commit 3c4f46d

Please sign in to comment.