Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/strategies.py
Show First 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | def origin_with_releases(): | ||||
tests_data = get_tests_data() | tests_data = get_tests_data() | ||||
for origin in tests_data["origins"]: | for origin in tests_data["origins"]: | ||||
snapshot = snapshot_get_latest(tests_data["storage"], origin["url"]) | snapshot = snapshot_get_latest(tests_data["storage"], origin["url"]) | ||||
if any([b.target_type.value == "release" for b in snapshot.branches.values()]): | if any([b.target_type.value == "release" for b in snapshot.branches.values()]): | ||||
ret.append(origin) | ret.append(origin) | ||||
return sampled_from(ret) | return sampled_from(ret) | ||||
def origin_with_pull_request_branches(): | |||||
""" | |||||
Hypothesis strategy returning a random origin with pull request branches | |||||
ingested into the test archive. | |||||
""" | |||||
ret = [] | |||||
tests_data = get_tests_data() | |||||
storage = tests_data["storage"] | |||||
origins = storage.origin_list(limit=1000) | |||||
for origin in origins.results: | |||||
snapshot = snapshot_get_latest(storage, origin.url) | |||||
if any([b"refs/pull/" in b for b in snapshot.branches]): | |||||
ret.append(origin) | |||||
return sampled_from(ret) | |||||
def new_origin(): | def new_origin(): | ||||
""" | """ | ||||
Hypothesis strategy returning a random origin not ingested | Hypothesis strategy returning a random origin not ingested | ||||
into the test archive. | into the test archive. | ||||
""" | """ | ||||
return new_origin_strategy().filter( | return new_origin_strategy().filter( | ||||
lambda origin: get_tests_data()["storage"].origin_get([origin.url])[0] is None | lambda origin: get_tests_data()["storage"].origin_get([origin.url])[0] is None | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines |