diff --git a/src/geoserverx/_async/gsx.py b/src/geoserverx/_async/gsx.py index 48eb530..d313d79 100644 --- a/src/geoserverx/_async/gsx.py +++ b/src/geoserverx/_async/gsx.py @@ -361,10 +361,12 @@ async def reload_geoserver(self) -> GSResponse: """ Client = self.http_client responses = await Client.put( - "/reload",headers=self.head, + "/reload", + headers=self.head, ) results = self.response_recognise(responses.status_code) return results + # Get all geofence rules async def get_all_geofence_rules(self) -> Union[RulesResponse, GSResponse]: Client = self.http_client diff --git a/src/geoserverx/_sync/gsx.py b/src/geoserverx/_sync/gsx.py index ffec4de..f5103a1 100644 --- a/src/geoserverx/_sync/gsx.py +++ b/src/geoserverx/_sync/gsx.py @@ -491,6 +491,7 @@ def reload_geoserver(self) -> GSResponse: ) results = self.response_recognise(responses.status_code) return results + # Get all geofence rules @exception_handler def get_all_geofence_rules(self) -> Union[RulesResponse, GSResponse]: diff --git a/src/geoserverx/cli/cli.py b/src/geoserverx/cli/cli.py index d422ff8..c1f11f5 100644 --- a/src/geoserverx/cli/cli.py +++ b/src/geoserverx/cli/cli.py @@ -445,6 +445,8 @@ def geofence_rules( print(result) else: typer.echo("Async support will be shortly") + + # Reset geoserver @SyncGeoServerX.exception_handler @app.command(help="Reset geoserver settings") @@ -465,7 +467,8 @@ def reset( typer.secho(result, fg=typer.colors.GREEN) else: typer.echo("Async support will be shortly") - + + # get geofence rule @SyncGeoServerX.exception_handler @app.command(help="Get geofence rule in the Geoserver") @@ -490,7 +493,6 @@ def geofence_rule( print(result) else: typer.echo("Async support will be shortly") - # Reload geoserver @@ -513,5 +515,3 @@ def reload( typer.secho(result, fg=typer.colors.GREEN) else: typer.echo("Async support will be shortly") - - diff --git a/tests/_async/test_gsx.py b/tests/_async/test_gsx.py index fab3d6a..2b39dbe 100644 --- a/tests/_async/test_gsx.py +++ b/tests/_async/test_gsx.py @@ -478,6 +478,8 @@ async def test_reset_geoserver_validation( ) response = await create_a_client.reset_geoserver() assert response.code == 404 + + # Test - all_geofence_rules @pytest.mark.asyncio async def test_all_geofence_rules_validation( @@ -544,6 +546,7 @@ async def test_reload_geoserver_NetworkError(create_a_client, respx_mock): response = await create_a_client.reload_geoserver() assert response.response == "Error in connecting to Geoserver" + @pytest.mark.asyncio async def test_all_geofence_rules_success( create_a_client, respx_mock, good_all_geofence_rules_connection diff --git a/tests/conftest.py b/tests/conftest.py index b4a47ca..2b7c004 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -676,6 +676,8 @@ def networkbad_layer_groups_connection() -> dict: def good_reset_geoserver_connection() -> dict: item = {"code": 200, "response": "Executed successfully'"} return item + + @pytest.fixture def good_all_geofence_rules_connection() -> dict: item = { @@ -817,6 +819,8 @@ def good_all_geofence_rules_connection() -> dict: def bad_reset_geoserver_connection() -> dict: item = {"code": 404, "response": "Result not found"} return item + + @pytest.fixture def bad_all_geofence_rules_connection() -> dict: item = {"code": 404, "response": "Result not found"} @@ -827,6 +831,8 @@ def bad_all_geofence_rules_connection() -> dict: def invalid_reset_geoserver_connection() -> dict: item = {"code": 404, "response": "Result not found"} return item + + @pytest.fixture def networkbad_all_geofence_rules_connection() -> dict: item = {"code": 503, "response": "Geoserver unavailable"} @@ -837,6 +843,8 @@ def networkbad_all_geofence_rules_connection() -> dict: def good_reload_geoserver_connection() -> dict: item = {"code": 200, "response": "Executed successfully'"} return item + + @pytest.fixture def good_new_geofence_rule_connection() -> dict: item = { @@ -862,6 +870,8 @@ def good_new_geofence_rule_connection() -> dict: def bad_reload_geoserver_connection() -> dict: item = {"code": 404, "response": "Result not found"} return item + + @pytest.fixture def bad_new_geofence_rule_connection() -> dict: item = {"Rule": ""} @@ -872,6 +882,8 @@ def bad_new_geofence_rule_connection() -> dict: def invalid_reload_geoserver_connection() -> dict: item = {"code": 404, "response": "Result not found"} return item + + @pytest.fixture def invalid_new_geofence_rule_connection() -> dict: item = {"code": 404, "response": "Result not found"}