Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/test_journal_client.py
Show First 20 Lines • Show All 539 Lines • ▼ Show 20 Lines | ): | ||||
ovs = swh_scheduler.origin_visit_stats_get([("cavabarder", "git")])[0] | ovs = swh_scheduler.origin_visit_stats_get([("cavabarder", "git")])[0] | ||||
assert ovs.last_eventful == DATE1 + 5 * ONE_DAY | assert ovs.last_eventful == DATE1 + 5 * ONE_DAY | ||||
assert ovs.last_uneventful is None | assert ovs.last_uneventful is None | ||||
assert ovs.last_failed is None | assert ovs.last_failed is None | ||||
assert ovs.last_notfound is None | assert ovs.last_notfound is None | ||||
assert ovs.last_snapshot == hash_to_bytes( | assert ovs.last_snapshot == hash_to_bytes( | ||||
"5555555555555555555555555555555555555555" | "5555555555555555555555555555555555555555" | ||||
) | ) | ||||
def test_journal_client_origin_visit_status_duplicated_messages(swh_scheduler): | |||||
"""A duplicated message must be ignored | |||||
""" | |||||
visit_status = { | |||||
"origin": "foo", | |||||
"visit": 1, | |||||
"status": "full", | |||||
"date": DATE1, | |||||
"type": "git", | |||||
"snapshot": hash_to_bytes("aaaaaabbbeb6cf9efd5b920a8453e1e07157b6cd"), | |||||
} | |||||
process_journal_objects( | |||||
{"origin_visit_status": [visit_status]}, scheduler=swh_scheduler | |||||
) | |||||
process_journal_objects( | |||||
{"origin_visit_status": [visit_status]}, scheduler=swh_scheduler | |||||
) | |||||
expected_visit_stats = OriginVisitStats( | |||||
url="foo", | |||||
visit_type="git", | |||||
last_eventful=DATE1, | |||||
last_uneventful=None, | |||||
last_failed=None, | |||||
last_notfound=None, | |||||
last_snapshot=hash_to_bytes("aaaaaabbbeb6cf9efd5b920a8453e1e07157b6cd"), | |||||
) | |||||
assert swh_scheduler.origin_visit_stats_get([("foo", "git")]) == [ | |||||
expected_visit_stats | |||||
] |