Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/strategies.py
Show All 17 Lines | from hypothesis.strategies import ( | ||||
lists, | lists, | ||||
sampled_from, | sampled_from, | ||||
text, | text, | ||||
) | ) | ||||
from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | from swh.model.hashutil import DEFAULT_ALGORITHMS, hash_to_bytes, hash_to_hex | ||||
from swh.model.hypothesis_strategies import origins as new_origin_strategy | from swh.model.hypothesis_strategies import origins as new_origin_strategy | ||||
from swh.model.hypothesis_strategies import snapshots as new_snapshot | from swh.model.hypothesis_strategies import snapshots as new_snapshot | ||||
from swh.model.identifiers import ObjectType | |||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
Directory, | Directory, | ||||
Person, | Person, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 607 Lines • ▼ Show 20 Lines | def revision_with_submodules(): | ||||
""" | """ | ||||
return just( | return just( | ||||
{ | { | ||||
"rev_sha1_git": "ffcb69001f3f6745dfd5b48f72ab6addb560e234", | "rev_sha1_git": "ffcb69001f3f6745dfd5b48f72ab6addb560e234", | ||||
"rev_dir_sha1_git": "d92a21446387fa28410e5a74379c934298f39ae2", | "rev_dir_sha1_git": "d92a21446387fa28410e5a74379c934298f39ae2", | ||||
"rev_dir_rev_path": "libtess2", | "rev_dir_rev_path": "libtess2", | ||||
} | } | ||||
) | ) | ||||
def swhid(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for any object | |||||
ingested into the test archive. | |||||
""" | |||||
return _known_swh_object("swhids") | |||||
def content_swhid(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for a content object | |||||
ingested into the test archive. | |||||
""" | |||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.CONTENT) | |||||
def directory_swhid(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for a directory object | |||||
ingested into the test archive. | |||||
""" | |||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.DIRECTORY) | |||||
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(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for a revision object | |||||
ingested into the test archive. | |||||
""" | |||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.REVISION) | |||||
def snapshot_swhid(): | |||||
""" | |||||
Hypothesis strategy returning a qualified SWHID for a snapshot object | |||||
ingested into the test archive. | |||||
""" | |||||
return swhid().filter(lambda swhid: swhid.object_type == ObjectType.SNAPSHOT) |