Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hypothesis_strategies.py
Show All 12 Lines | from hypothesis.strategies import ( | ||||
builds, | builds, | ||||
characters, | characters, | ||||
composite, | composite, | ||||
datetimes, | datetimes, | ||||
dictionaries, | dictionaries, | ||||
from_regex, | from_regex, | ||||
integers, | integers, | ||||
just, | just, | ||||
lists, | |||||
none, | none, | ||||
one_of, | one_of, | ||||
sampled_from, | sampled_from, | ||||
sets, | sets, | ||||
text, | text, | ||||
tuples, | tuples, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
def releases(): | def releases(): | ||||
return releases_d().map(Release.from_dict) | return releases_d().map(Release.from_dict) | ||||
revision_metadata = metadata_dicts | revision_metadata = metadata_dicts | ||||
def extra_headers(): | |||||
return lists(tuples(text(), text())).map(tuple) | |||||
olasd: I'm not sure we should allow empty keys. Of course, that will make validation more annoying in… | |||||
Done Inline ActionsI wasn't sure about this. But each time (almost) we forbid a "degenerated" case, we can find a degenerated repo that somewhat managed to have it... douardda: I wasn't sure about this. But each time (almost) we forbid a "degenerated" case, we can find a… | |||||
def revisions_d(): | def revisions_d(): | ||||
return builds( | return builds( | ||||
dict, | dict, | ||||
message=optional(binary()), | message=optional(binary()), | ||||
synthetic=booleans(), | synthetic=booleans(), | ||||
author=persons_d(), | author=persons_d(), | ||||
committer=persons_d(), | committer=persons_d(), | ||||
date=timestamps_with_timezone_d(), | date=timestamps_with_timezone_d(), | ||||
committer_date=timestamps_with_timezone_d(), | committer_date=timestamps_with_timezone_d(), | ||||
parents=tuples(sha1_git()), | parents=tuples(sha1_git()), | ||||
directory=sha1_git(), | directory=sha1_git(), | ||||
type=sampled_from([x.value for x in RevisionType]), | type=sampled_from([x.value for x in RevisionType]), | ||||
metadata=optional(revision_metadata()), | metadata=optional(revision_metadata()), | ||||
extra_headers=extra_headers(), | |||||
) | ) | ||||
# TODO: metadata['extra_headers'] can have binary keys and values | # TODO: metadata['extra_headers'] can have binary keys and values | ||||
def revisions(): | def revisions(): | ||||
return revisions_d().map(Revision.from_dict) | return revisions_d().map(Revision.from_dict) | ||||
▲ Show 20 Lines • Show All 209 Lines • Show Last 20 Lines |
I'm not sure we should allow empty keys. Of course, that will make validation more annoying in the model.