diff --git a/pyle38/errors.py b/pyle38/errors.py index b2e3ec6..bc04264 100644 --- a/pyle38/errors.py +++ b/pyle38/errors.py @@ -12,3 +12,7 @@ class Tile38KeyNotFoundError(Exception): class Tile38NotCaughtUpError(Exception): pass + + +class Tile38PathNotFoundError(Exception): + pass diff --git a/pyle38/parse_response.py b/pyle38/parse_response.py index e9bc493..be77ab1 100644 --- a/pyle38/parse_response.py +++ b/pyle38/parse_response.py @@ -8,6 +8,7 @@ Tile38IdNotFoundError, Tile38KeyNotFoundError, Tile38NotCaughtUpError, + Tile38PathNotFoundError, ) @@ -38,6 +39,9 @@ def parse_response( if "not caught up" in msg: raise Tile38NotCaughtUpError(msg) + if "path not found" in msg: + raise Tile38PathNotFoundError(msg) + raise Tile38Error(msg) return obj diff --git a/tests/test_command_jget_jset_jdel.py b/tests/test_command_jget_jset_jdel.py index 89a6ab3..ac440a9 100644 --- a/tests/test_command_jget_jset_jdel.py +++ b/tests/test_command_jget_jset_jdel.py @@ -1,5 +1,9 @@ import pytest +from pyle38.errors import Tile38KeyNotFoundError, Tile38PathNotFoundError + +from .helper.random_data import random_string + @pytest.mark.asyncio async def test_command_jset_jget_jdel(tile38_with_follower): @@ -35,7 +39,11 @@ async def test_command_j_options(tile38): assert response.ok response = await tile38.jget("linestring", "1") - response.ok - response.value == '{"type":"LineString","coordinates":[[0,0],[1,1],[2,2]]}' + assert response.ok + assert response.value == '{"type":"LineString","coordinates":[[0,0],[1,1],[2,2]]}' + + with pytest.raises(Tile38KeyNotFoundError): + await tile38.jdel(random_string(), random_string(), random_string()) - # TODO: test for raise Tile38Error on deleted key + with pytest.raises(Tile38PathNotFoundError): + await tile38.jdel("linestring", random_string(), random_string())