Skip to content

Commit

Permalink
* fix: resource calls
Browse files Browse the repository at this point in the history
* test: add resource calls tests
  • Loading branch information
mcebria-hg committed Jan 22, 2025
1 parent f878964 commit d82b4c8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

#### Fixed

- Fix resource calls endpoints (#16).

#### Added

- Added CI/CD pipeline for pre-commit, tests...
Expand Down
8 changes: 4 additions & 4 deletions geoserver/geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ def get_resource(
geoserver.get_resource(resource="styles/default_point.sld", operation="default")
```
"""
url = f"{self.service_url}/rest/resources/{path}.{format}"
url = f"{self.service_url}/rest/resource/{path}"
params = dict(operation=operation, format="json")
response = self._request(method="get", url=url, params=params)
return response.json() if format == "json" else response.text
Expand All @@ -2175,7 +2175,7 @@ def update_resource(self, path: str, body: Union[str, Dict[str, Any]]) -> str:
Returns:
Success message.
"""
url = f"{self.service_url}/rest/resources/{path}"
url = f"{self.service_url}/rest/resource/{path}"
self._request(method="put", url=url, body=body)
return UPDATED_MESSAGE

Expand All @@ -2188,7 +2188,7 @@ def delete_resource(self, path: str) -> str:
Returns:
Success message.
"""
url = f"{self.service_url}/rest/resources/{path}"
url = f"{self.service_url}/rest/resource/{path}"
self._request(method="delete", url=url)
return DELETED_MESSAGE

Expand All @@ -2201,7 +2201,7 @@ def resource_exists(self, path: str) -> bool:
Returns:
Success message.
"""
url = f"{self.service_url}/rest/resources/{path}"
url = f"{self.service_url}/rest/resource/{path}"
response = self._request(method="head", url=url, ignore=[404])
return response.status_code == 200

Expand Down
21 changes: 14 additions & 7 deletions tests/test_geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,24 +873,31 @@ def test_reload(test_geoserver: GeoServer) -> None:
# Resources


@pytest.mark.skip("Not implemented yet.")
@pytest.mark.skipif(not GEOSERVER_RUNNING, reason=f"No GeoServer running at {GEOSERVER_URL!r}.")
def test_get_resource(test_geoserver: GeoServer) -> None: ...
def test_get_resource(test_geoserver: GeoServer, test_workspace: str) -> None:
path = f"data/{test_workspace}"
data = test_geoserver.get_resource(path)
assert isinstance(data, dict)


@pytest.mark.skip("Not implemented yet.")
@pytest.mark.skipif(not GEOSERVER_RUNNING, reason=f"No GeoServer running at {GEOSERVER_URL!r}.")
def test_update_resource(test_geoserver: GeoServer) -> None: ...
def test_head_resource(test_geoserver: GeoServer, test_workspace: str) -> None:
path = f"data/{test_workspace}"
data = test_geoserver.resource_exists(path)
assert isinstance(data, bool)
assert data


@pytest.mark.skip("Not implemented yet.")
@pytest.mark.skipif(not GEOSERVER_RUNNING, reason=f"No GeoServer running at {GEOSERVER_URL!r}.")
def test_delete_resource(test_geoserver: GeoServer) -> None: ...
def test_update_resource(test_geoserver: GeoServer) -> None: ...


@pytest.mark.skip("Not implemented yet.")
@pytest.mark.skipif(not GEOSERVER_RUNNING, reason=f"No GeoServer running at {GEOSERVER_URL!r}.")
def test_head_resource(test_geoserver: GeoServer) -> None: ...
def test_delete_resource(test_geoserver: GeoServer, test_workspace: str, test_coverage: str) -> None:
path = f"data/{test_workspace}/{test_coverage}"
msg = test_geoserver.delete_resource(path)
assert isinstance(msg, str)


# Security
Expand Down

0 comments on commit d82b4c8

Please sign in to comment.