Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/strategies.py
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | return lists( | ||||
timezones=timezones(), | timezones=timezones(), | ||||
), | ), | ||||
min_size=min_size, | min_size=min_size, | ||||
max_size=max_size, | max_size=max_size, | ||||
unique=True, | unique=True, | ||||
).map(sorted) | ).map(sorted) | ||||
def release(): | |||||
""" | |||||
Hypothesis strategy returning a random release ingested | |||||
into the test archive. | |||||
""" | |||||
return _known_swh_object("releases") | |||||
def releases(min_size=2, max_size=8): | |||||
""" | |||||
Hypothesis strategy returning random releases ingested | |||||
into the test archive. | |||||
""" | |||||
return lists(release(), min_size=min_size, max_size=max_size) | |||||
def unknown_release(): | def unknown_release(): | ||||
""" | """ | ||||
Hypothesis strategy returning a random revision not ingested | Hypothesis strategy returning a random revision not ingested | ||||
into the test archive. | into the test archive. | ||||
""" | """ | ||||
return sha1().filter( | return sha1().filter( | ||||
lambda s: get_tests_data()["storage"].release_get([s])[0] is None | lambda s: get_tests_data()["storage"].release_get([s])[0] is None | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | |||||
def swhid(): | def swhid(): | ||||
""" | """ | ||||
Hypothesis strategy returning a qualified SWHID for any object | Hypothesis strategy returning a qualified SWHID for any object | ||||
ingested into the test archive. | ingested into the test archive. | ||||
""" | """ | ||||
return _known_swh_object("swhids") | return _known_swh_object("swhids") | ||||
def release_swhid(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for a release object | |||||
ingested into the test archive. | |||||
""" | |||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.RELEASE) | |||||
def revision_swhid(): | def revision_swhid(): | ||||
""" | """ | ||||
Hypothesis strategy returning a qualified SWHID for a revision object | Hypothesis strategy returning a qualified SWHID for a revision object | ||||
ingested into the test archive. | ingested into the test archive. | ||||
""" | """ | ||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.REVISION) | return swhid().filter(lambda swhid: swhid.object_type == ObjectType.REVISION) | ||||
def snapshot_swhid(): | def snapshot_swhid(): | ||||
""" | """ | ||||
Hypothesis strategy returning a qualified SWHID for a snapshot object | Hypothesis strategy returning a qualified SWHID for a snapshot object | ||||
ingested into the test archive. | ingested into the test archive. | ||||
""" | """ | ||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.SNAPSHOT) | return swhid().filter(lambda swhid: swhid.object_type == ObjectType.SNAPSHOT) |