Skip to content

Commit

Permalink
fix: change resource url (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcebria-hg authored Jan 27, 2025
1 parent 31be781 commit a65c8cf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 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. Run tests and linter on PRs.
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
24 changes: 18 additions & 6 deletions tests/test_geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,24 +873,36 @@ 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) -> None: ...


@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) -> None:
coveragestore = "tmp-coveragestore"
file_path = Path(TEST_DATA_DIR, "rasters", "raster.tif").resolve()
test_geoserver.upload_coverage_store(
file=file_path,
name=coveragestore,
workspace=test_workspace,
format="geotiff",
)
path = f"data/{test_workspace}/{coveragestore}"
msg = test_geoserver.delete_resource(path)
assert isinstance(msg, str)


# Security
Expand Down

0 comments on commit a65c8cf

Please sign in to comment.