Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/functional/test_visit_node.py
Show All 19 Lines | query_str = """ | ||||
latestStatus { | latestStatus { | ||||
status | status | ||||
date | date | ||||
type | type | ||||
snapshot { | snapshot { | ||||
swhid | swhid | ||||
} | } | ||||
} | } | ||||
status { | statuses { | ||||
nodes { | nodes { | ||||
status | status | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
""" | """ | ||||
Show All 9 Lines | for vws in visits_and_statuses: | ||||
"latestStatus": { | "latestStatus": { | ||||
"date": statuses[-1].date.isoformat(), | "date": statuses[-1].date.isoformat(), | ||||
"type": statuses[-1].type, | "type": statuses[-1].type, | ||||
"status": statuses[-1].status, | "status": statuses[-1].status, | ||||
"snapshot": ({"swhid": f"swh:1:snp:{statuses[-1].snapshot.hex()}"}) | "snapshot": ({"swhid": f"swh:1:snp:{statuses[-1].snapshot.hex()}"}) | ||||
if statuses[-1].snapshot | if statuses[-1].snapshot | ||||
else None, | else None, | ||||
}, | }, | ||||
"status": {"nodes": [{"status": status.status} for status in statuses]}, | "statuses": {"nodes": [{"status": status.status} for status in statuses]}, | ||||
} | } | ||||
def test_invalid_get_visit(client): | def test_invalid_get_visit(client): | ||||
query_str = """ | query_str = """ | ||||
{ | { | ||||
visit(originUrl: "http://example.com/forge1", visitId: 3) { | visit(originUrl: "http://example.com/forge1", visitId: 3) { | ||||
type | type | ||||
} | } | ||||
} | } | ||||
""" | """ | ||||
assert_missing_object(client, query_str, "visit") | assert_missing_object(client, query_str, "visit") | ||||
def test_get_latest_visit_status_filter_by_status_return_null(client): | |||||
query_str = """ | |||||
{ | |||||
visit(originUrl: "%s", visitId: %s) { | |||||
visitId | |||||
date | |||||
type | |||||
latestStatus(allowedStatuses: [full]) { | |||||
status | |||||
} | |||||
} | |||||
} | |||||
""" % ( | |||||
get_origins()[0].url, | |||||
1, | |||||
) | |||||
data, err = get_query_response(client, query_str) | |||||
assert err is None | |||||
assert data == { | |||||
"visit": { | |||||
"date": "2013-05-07T04:20:39.369271+00:00", | |||||
"latestStatus": None, | |||||
"type": "git", | |||||
"visitId": 1, | |||||
} | |||||
} | |||||
def test_get_latest_visit_status_filter_by_type(client): | |||||
query_str = """ | |||||
{ | |||||
visit(originUrl: "%s", visitId: %s) { | |||||
visitId | |||||
date | |||||
type | |||||
latestStatus(allowedStatuses: [ongoing]) { | |||||
status | |||||
date | |||||
} | |||||
} | |||||
} | |||||
""" % ( | |||||
get_origins()[0].url, | |||||
1, | |||||
) | |||||
data, err = get_query_response(client, query_str) | |||||
assert err is None | |||||
assert data == { | |||||
"visit": { | |||||
"date": "2013-05-07T04:20:39.369271+00:00", | |||||
"latestStatus": { | |||||
"date": "2013-05-07T04:20:39.432222+00:00", | |||||
"status": "ongoing", | |||||
}, | |||||
"type": "git", | |||||
"visitId": 1, | |||||
} | |||||
} | |||||
def test_get_latest_visit_status_filter_by_snapshot(client): | |||||
query_str = """ | |||||
{ | |||||
visit(originUrl: "%s", visitId: %s) { | |||||
visitId | |||||
date | |||||
type | |||||
latestStatus(requireSnapshot: true) { | |||||
status | |||||
date | |||||
snapshot { | |||||
swhid | |||||
} | |||||
} | |||||
} | |||||
} | |||||
""" % ( | |||||
get_origins()[1].url, | |||||
2, | |||||
) | |||||
data, err = get_query_response(client, query_str) | |||||
assert err is None | |||||
assert data == { | |||||
"visit": { | |||||
"date": "2015-11-27T17:20:39+00:00", | |||||
"latestStatus": { | |||||
anlambert: Could you ask for the snapshot in the query and test it is not null in the result ? This will… | |||||
"date": "2015-11-27T17:22:18+00:00", | |||||
"snapshot": { | |||||
"swhid": "swh:1:snp:0e7f84ede9a254f2cd55649ad5240783f557e65f" | |||||
}, | |||||
"status": "partial", | |||||
}, | |||||
"type": "hg", | |||||
"visitId": 2, | |||||
} | |||||
} |
Could you ask for the snapshot in the query and test it is not null in the result ? This will make your test more consistent.