Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/functional/test_content.py
Show First 20 Lines • Show All 227 Lines • ▼ Show 20 Lines | def test_get_content_as_target(client): | ||||
# SWHID of a test dir with a file entry | # SWHID of a test dir with a file entry | ||||
directory_swhid = "swh:1:dir:87b339104f7dc2a8163dec988445e3987995545f" | directory_swhid = "swh:1:dir:87b339104f7dc2a8163dec988445e3987995545f" | ||||
query_str = """ | query_str = """ | ||||
query getDirectory($swhid: SWHID!) { | query getDirectory($swhid: SWHID!) { | ||||
directory(swhid: $swhid) { | directory(swhid: $swhid) { | ||||
swhid | swhid | ||||
entries(first: 2) { | entries(first: 2) { | ||||
nodes { | nodes { | ||||
targetType | |||||
target { | target { | ||||
type | |||||
identifier | |||||
node { | |||||
...on Content { | ...on Content { | ||||
swhid | swhid | ||||
length | length | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
""" | """ | ||||
data, _ = utils.get_query_response(client, query_str, swhid=directory_swhid) | data, _ = utils.get_query_response(client, query_str, swhid=directory_swhid) | ||||
content_obj = data["directory"]["entries"]["nodes"][1]["target"] | content_obj = data["directory"]["entries"]["nodes"][1]["target"] | ||||
assert content_obj == { | assert content_obj == { | ||||
"type": "content", | |||||
"identifier": "86bc6b377e9d25f9d26777a4a28d08e63e7c5779", | |||||
"node": { | |||||
"length": 4, | "length": 4, | ||||
"swhid": "swh:1:cnt:86bc6b377e9d25f9d26777a4a28d08e63e7c5779", | "swhid": "swh:1:cnt:86bc6b377e9d25f9d26777a4a28d08e63e7c5779", | ||||
}, | |||||
} | } |