Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/strategies.py
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | def unknown_snapshot(): | ||||
Hypothesis strategy returning a random revision not ingested | Hypothesis strategy returning a random revision not ingested | ||||
into the test archive. | into the test archive. | ||||
""" | """ | ||||
storage = get_tests_data()['storage'] | storage = get_tests_data()['storage'] | ||||
return sha1().filter( | return sha1().filter( | ||||
lambda s: storage.snapshot_get(hash_to_bytes(s)) is None) | lambda s: storage.snapshot_get(hash_to_bytes(s)) is None) | ||||
def person(): | |||||
""" | |||||
Hypothesis strategy returning a random person ingested | |||||
into the test archive. | |||||
""" | |||||
return _known_swh_object('persons') | |||||
def unknown_person(): | |||||
""" | |||||
Hypothesis strategy returning a random person not ingested | |||||
into the test archive. | |||||
""" | |||||
return integers(min_value=1000000) | |||||
def _get_origin_dfs_revisions_walker(): | def _get_origin_dfs_revisions_walker(): | ||||
tests_data = get_tests_data() | tests_data = get_tests_data() | ||||
storage = tests_data['storage'] | storage = tests_data['storage'] | ||||
origin = random.choice(tests_data['origins'][:-1]) | origin = random.choice(tests_data['origins'][:-1]) | ||||
snapshot = storage.snapshot_get_latest(origin['url']) | snapshot = storage.snapshot_get_latest(origin['url']) | ||||
head = snapshot['branches'][b'HEAD']['target'] | head = snapshot['branches'][b'HEAD']['target'] | ||||
return get_revisions_walker('dfs', storage, head) | return get_revisions_walker('dfs', storage, head) | ||||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |