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 directory_identifier | |||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Content, | Content, | ||||
Directory, | |||||
Person, | Person, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
from swh.storage.algos.revisions_walker import get_revisions_walker | from swh.storage.algos.revisions_walker import get_revisions_walker | ||||
from swh.storage.algos.snapshot import snapshot_get_latest | from swh.storage.algos.snapshot import snapshot_get_latest | ||||
from swh.web.common.utils import browsers_supported_image_mimes | from swh.web.common.utils import browsers_supported_image_mimes | ||||
▲ Show 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | def directory_with_subdirs(): | ||||
) | ) | ||||
def empty_directory(): | def empty_directory(): | ||||
""" | """ | ||||
Hypothesis strategy returning the empty directory ingested | Hypothesis strategy returning the empty directory ingested | ||||
into the test archive. | into the test archive. | ||||
""" | """ | ||||
return just(directory_identifier({"entries": []})) | return just(Directory(entries=()).id.hex()) | ||||
def unknown_directory(): | def unknown_directory(): | ||||
""" | """ | ||||
Hypothesis strategy returning a random directory not ingested | Hypothesis strategy returning a random directory not ingested | ||||
into the test archive. | into the test archive. | ||||
""" | """ | ||||
return sha1().filter( | return sha1().filter( | ||||
▲ Show 20 Lines • Show All 361 Lines • Show Last 20 Lines |