Skip to content

Commit

Permalink
Test workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
vuilleumierc committed Aug 22, 2024
1 parent b7c1c88 commit cc0e3d9
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
2 changes: 1 addition & 1 deletion geoservercloud/geoservercloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def publish_gwc_layer(
self.post_request(
"/gwc/rest/reload",
headers={"Content-Type": "application/json"},
data="reload_configuration=1",
data="reload_configuration=1", # type: ignore
)
payload = Templates.gwc_layer(workspace, layer, f"EPSG:{epsg}")
return self.put_request(
Expand Down
22 changes: 21 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ xmltodict = "0.13.0"

[tool.poetry.group.dev.dependencies]
pytest = "8.2.2"
responses = "0.25.3"

[build-system]
requires = [
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

from geoservercloud import GeoServerCloud

GEOSERVER_URL = "http://localhost:8080/geoserver"


@pytest.fixture(scope="session")
def geoserver():
geoserver = GeoServerCloud(url=GEOSERVER_URL)
yield geoserver
52 changes: 52 additions & 0 deletions tests/test_workspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import responses
from conftest import GEOSERVER_URL

from geoservercloud.geoservercloud import GeoServerCloud


def test_create_workspace(geoserver: GeoServerCloud) -> None:
workspace = "test_workspace"

with responses.RequestsMock() as rsps:
rsps.post(
url=f"{GEOSERVER_URL}/rest/workspaces.json",
status=201,
)

response = geoserver.create_workspace(workspace)

assert response.status_code == 201


@responses.activate
def test_update_workspace(geoserver: GeoServerCloud) -> None:
workspace = "test_workspace"

with responses.RequestsMock() as rsps:
rsps.post(
url=f"{GEOSERVER_URL}/rest/workspaces.json",
status=409,
)
rsps.put(
url=f"{GEOSERVER_URL}/rest/workspaces/{workspace}.json",
status=200,
)

response = geoserver.create_workspace(workspace)

assert response.status_code == 200


@responses.activate
def test_delete_workspace(geoserver: GeoServerCloud) -> None:
workspace = "test_workspace"

with responses.RequestsMock() as rsps:
rsps.delete(
url=f"{GEOSERVER_URL}/rest/workspaces/{workspace}.json",
status=200,
)

response = geoserver.delete_workspace(workspace)

assert response.status_code == 200

0 comments on commit cc0e3d9

Please sign in to comment.