Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/functional/test_branch_connection.py
Show All 12 Lines | def get_branches(client, **kwargs) -> tuple: | ||||
query getSnapshot($swhid: SWHID!, $first: Int!, $after: String, $types: [BranchTargetType], | query getSnapshot($swhid: SWHID!, $first: Int!, $after: String, $types: [BranchTargetType], | ||||
$nameInclude: String, $excludePrefix: String) { | $nameInclude: String, $excludePrefix: String) { | ||||
snapshot(swhid: $swhid) { | snapshot(swhid: $swhid) { | ||||
branches(first: $first, after: $after, types: $types, nameInclude: $nameInclude, | branches(first: $first, after: $after, types: $types, nameInclude: $nameInclude, | ||||
nameExcludePrefix: $excludePrefix ) { | nameExcludePrefix: $excludePrefix ) { | ||||
pageInfo { | pageInfo { | ||||
endCursor | endCursor | ||||
} | } | ||||
edges { | |||||
cursor | |||||
} | |||||
nodes { | nodes { | ||||
targetType | targetType | ||||
name { | name { | ||||
text | text | ||||
} | } | ||||
target { | target { | ||||
__typename | __typename | ||||
...on Branch { | ...on Branch { | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
def test_get_after_arg(client): | def test_get_after_arg(client): | ||||
swhid = "swh:1:snp:0e7f84ede9a254f2cd55649ad5240783f557e65f" | swhid = "swh:1:snp:0e7f84ede9a254f2cd55649ad5240783f557e65f" | ||||
first_data, _ = get_branches(client, swhid=swhid, first=1) | first_data, _ = get_branches(client, swhid=swhid, first=1) | ||||
end_cursor = first_data["snapshot"]["branches"]["pageInfo"]["endCursor"] | end_cursor = first_data["snapshot"]["branches"]["pageInfo"]["endCursor"] | ||||
node_name = first_data["snapshot"]["branches"]["nodes"][0]["name"]["text"] | node_name = first_data["snapshot"]["branches"]["nodes"][0]["name"]["text"] | ||||
second_data, _ = get_branches(client, swhid=swhid, first=3, after=end_cursor) | second_data, _ = get_branches(client, swhid=swhid, first=3, after=end_cursor) | ||||
branches = second_data["snapshot"]["branches"] | branches = second_data["snapshot"]["branches"] | ||||
assert len(branches["nodes"]) == 3 | assert len(branches["nodes"]) == 3 | ||||
assert branches["edges"][0]["cursor"] == end_cursor | |||||
for node in branches["nodes"]: | for node in branches["nodes"]: | ||||
assert node["name"]["text"] > node_name | assert node["name"]["text"] > node_name |