diff --git a/requirements-swh.txt b/requirements-swh.txt --- a/requirements-swh.txt +++ b/requirements-swh.txt @@ -1,2 +1,2 @@ -swh.core[http] >= 0.0.63 +swh.core[http] >= 0.0.79 swh.model diff --git a/swh/graph/client.py b/swh/graph/client.py --- a/swh/graph/client.py +++ b/swh/graph/client.py @@ -24,6 +24,7 @@ def raw_verb_lines(self, verb, endpoint, **kwargs): response = self.raw_verb(verb, endpoint, stream=True, **kwargs) + self.check_status(response) for line in response.iter_lines(): yield line.decode().lstrip('\n') diff --git a/swh/graph/tests/test_api_client.py b/swh/graph/tests/test_api_client.py --- a/swh/graph/tests/test_api_client.py +++ b/swh/graph/tests/test_api_client.py @@ -1,6 +1,11 @@ import pytest +from pytest import raises + +from swh.core.api import RemoteException + + def test_stats(graph_client): stats = graph_client.stats() @@ -153,3 +158,33 @@ direction='backward' ) assert actual == 3 + + +def test_param_validation(graph_client): + with raises(RemoteException): # PID not found + list(graph_client.leaves( + 'swh:1:ori:fff0000000000000000000000000000000000021')) + with raises(RemoteException): # malformed PID + list(graph_client.neighbors( + 'swh:1:ori:fff000000zzzzzz0000000000000000000000021')) + with raises(RemoteException): # malformed edge specificaiton + list(graph_client.walk( + 'swh:1:dir:0000000000000000000000000000000000000016', 'rel', + edges='dir:notanodetype,dir:rev,rev:*', + direction='backward', + traversal='bfs', + )) + with raises(RemoteException): # malformed direction + list(graph_client.walk( + 'swh:1:dir:0000000000000000000000000000000000000016', 'rel', + edges='dir:dir,dir:rev,rev:*', + direction='notadirection', + traversal='bfs', + )) + with raises(RemoteException): # malformed traversal order + list(graph_client.walk( + 'swh:1:dir:0000000000000000000000000000000000000016', 'rel', + edges='dir:dir,dir:rev,rev:*', + direction='backward', + traversal='notatraversalorder', + ))