Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/test_api_client.py
Show First 20 Lines • Show All 285 Lines • ▼ Show 20 Lines | actual = graph_client.count_neighbors( | ||||
"swh:1:rev:0000000000000000000000000000000000000009", direction="backward" | "swh:1:rev:0000000000000000000000000000000000000009", direction="backward" | ||||
) | ) | ||||
assert actual == 3 | assert actual == 3 | ||||
def test_param_validation(graph_client): | def test_param_validation(graph_client): | ||||
with raises(GraphArgumentException) as exc_info: # SWHID not found | with raises(GraphArgumentException) as exc_info: # SWHID not found | ||||
list(graph_client.leaves("swh:1:ori:fff0000000000000000000000000000000000021")) | list(graph_client.leaves("swh:1:ori:fff0000000000000000000000000000000000021")) | ||||
if exc_info.value.response: | |||||
assert exc_info.value.response.status_code == 404 | assert exc_info.value.response.status_code == 404 | ||||
with raises(GraphArgumentException) as exc_info: # malformed SWHID | with raises(GraphArgumentException) as exc_info: # malformed SWHID | ||||
list( | list( | ||||
graph_client.neighbors("swh:1:ori:fff000000zzzzzz0000000000000000000000021") | graph_client.neighbors("swh:1:ori:fff000000zzzzzz0000000000000000000000021") | ||||
) | ) | ||||
if exc_info.value.response: | |||||
assert exc_info.value.response.status_code == 400 | assert exc_info.value.response.status_code == 400 | ||||
with raises(GraphArgumentException) as exc_info: # malformed edge specificaiton | with raises(GraphArgumentException) as exc_info: # malformed edge specificaiton | ||||
list( | list( | ||||
graph_client.visit_nodes( | graph_client.visit_nodes( | ||||
"swh:1:dir:0000000000000000000000000000000000000016", | "swh:1:dir:0000000000000000000000000000000000000016", | ||||
edges="dir:notanodetype,dir:rev,rev:*", | edges="dir:notanodetype,dir:rev,rev:*", | ||||
direction="backward", | direction="backward", | ||||
) | ) | ||||
) | ) | ||||
if exc_info.value.response: | |||||
assert exc_info.value.response.status_code == 400 | assert exc_info.value.response.status_code == 400 | ||||
with raises(GraphArgumentException) as exc_info: # malformed direction | with raises(GraphArgumentException) as exc_info: # malformed direction | ||||
list( | list( | ||||
graph_client.visit_nodes( | graph_client.visit_nodes( | ||||
"swh:1:dir:0000000000000000000000000000000000000016", | "swh:1:dir:0000000000000000000000000000000000000016", | ||||
edges="dir:dir,dir:rev,rev:*", | edges="dir:dir,dir:rev,rev:*", | ||||
direction="notadirection", | direction="notadirection", | ||||
) | ) | ||||
) | ) | ||||
if exc_info.value.response: | |||||
assert exc_info.value.response.status_code == 400 | assert exc_info.value.response.status_code == 400 | ||||
@pytest.mark.skip(reason="currently disabled due to T1969") | @pytest.mark.skip(reason="currently disabled due to T1969") | ||||
def test_param_validation_walk(graph_client): | def test_param_validation_walk(graph_client): | ||||
"""test validation of walk-specific parameters only""" | """test validation of walk-specific parameters only""" | ||||
with raises(RemoteException) as exc_info: # malformed traversal order | with raises(RemoteException) as exc_info: # malformed traversal order | ||||
list( | list( | ||||
graph_client.walk( | graph_client.walk( | ||||
"swh:1:dir:0000000000000000000000000000000000000016", | "swh:1:dir:0000000000000000000000000000000000000016", | ||||
"rel", | "rel", | ||||
edges="dir:dir,dir:rev,rev:*", | edges="dir:dir,dir:rev,rev:*", | ||||
direction="backward", | direction="backward", | ||||
traversal="notatraversalorder", | traversal="notatraversalorder", | ||||
) | ) | ||||
) | ) | ||||
assert exc_info.value.response.status_code == 400 | assert exc_info.value.response.status_code == 400 |