Changeset View
Changeset View
Standalone View
Standalone View
swh/graph/tests/test_api_client.py
import os | |||||
import pytest | |||||
pytestmark = pytest.mark.skipif(os.environ.get('JENKINS'), reason='T2055') | |||||
def test_stats(graph_client): | def test_stats(graph_client): | ||||
stats = graph_client.stats() | stats = graph_client.stats() | ||||
assert set(stats.keys()) == {'counts', 'ratios', 'indegree', | assert set(stats.keys()) == {'counts', 'ratios', 'indegree', | ||||
'outdegree'} | 'outdegree'} | ||||
assert set(stats['counts'].keys()) == {'nodes', 'edges'} | assert set(stats['counts'].keys()) == {'nodes', 'edges'} | ||||
assert set(stats['ratios'].keys()) == {'compression', 'bits_per_node', | assert set(stats['ratios'].keys()) == {'compression', 'bits_per_node', | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | expected = [ | ||||
'swh:1:dir:0000000000000000000000000000000000000017', | 'swh:1:dir:0000000000000000000000000000000000000017', | ||||
'swh:1:rev:0000000000000000000000000000000000000018', | 'swh:1:rev:0000000000000000000000000000000000000018', | ||||
'swh:1:rel:0000000000000000000000000000000000000019' | 'swh:1:rel:0000000000000000000000000000000000000019' | ||||
] | ] | ||||
assert set(actual) == set(expected) | assert set(actual) == set(expected) | ||||
def test_count(graph_client): | def test_count(graph_client): | ||||
print(graph_client) | |||||
actual = graph_client.count_leaves( | actual = graph_client.count_leaves( | ||||
'swh:1:ori:0000000000000000000000000000000000000021' | 'swh:1:ori:0000000000000000000000000000000000000021' | ||||
) | ) | ||||
assert actual == 4 | assert actual == 4 | ||||
actual = graph_client.count_visit_nodes( | actual = graph_client.count_visit_nodes( | ||||
'swh:1:rel:0000000000000000000000000000000000000010', | 'swh:1:rel:0000000000000000000000000000000000000010', | ||||
edges='rel:rev,rev:rev' | edges='rel:rev,rev:rev' | ||||
) | ) | ||||
assert actual == 3 | assert actual == 3 | ||||
actual = graph_client.count_neighbors( | actual = graph_client.count_neighbors( | ||||
'swh:1:rev:0000000000000000000000000000000000000009', | 'swh:1:rev:0000000000000000000000000000000000000009', | ||||
direction='backward' | direction='backward' | ||||
) | ) | ||||
assert actual == 3 | assert actual == 3 |