Skip to content

Commit

Permalink
chore: 🔧 add Tile38PathNotFoundError
Browse files Browse the repository at this point in the history
  • Loading branch information
iwpnd committed Nov 30, 2022
1 parent ddc3f4a commit 63b12f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pyle38/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ class Tile38KeyNotFoundError(Exception):

class Tile38NotCaughtUpError(Exception):
pass


class Tile38PathNotFoundError(Exception):
pass
4 changes: 4 additions & 0 deletions pyle38/parse_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Tile38IdNotFoundError,
Tile38KeyNotFoundError,
Tile38NotCaughtUpError,
Tile38PathNotFoundError,
)


Expand Down Expand Up @@ -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
14 changes: 11 additions & 3 deletions tests/test_command_jget_jset_jdel.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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())

0 comments on commit 63b12f4

Please sign in to comment.