Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hypothesis_strategies.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import attr | |||||
import datetime | import datetime | ||||
from hypothesis.strategies import ( | from hypothesis.strategies import ( | ||||
binary, builds, characters, composite, dictionaries, from_regex, | binary, builds, characters, composite, dictionaries, from_regex, | ||||
integers, just, lists, none, one_of, sampled_from, text, tuples, | integers, just, lists, none, one_of, sampled_from, text, tuples, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | def releases(draw): | ||||
(date, author) = draw(one_of( | (date, author) = draw(one_of( | ||||
tuples(none(), none()), | tuples(none(), none()), | ||||
tuples(timestamps_with_timezone(), persons()))) | tuples(timestamps_with_timezone(), persons()))) | ||||
rel = draw(builds( | rel = draw(builds( | ||||
Release, | Release, | ||||
id=sha1_git(), | id=sha1_git(), | ||||
author=none(), | author=none(), | ||||
date=none(), | date=none(), | ||||
target=sha1_git())) | target=sha1_git())) | ||||
rel.date = date | return attr.evolve( | ||||
rel.author = author | rel, | ||||
return rel | date=date, | ||||
author=author) | |||||
vlorentz: I'd like this to be two different statement (one for draw + builds, one for evolve), for… | |||||
Done Inline Actionsok but what about the combo in test_todict_origin_visits() below then ;-) douardda: ok but what about the combo in test_todict_origin_visits() below then ;-) | |||||
Not Done Inline Actions* shrug * vlorentz: %%% * shrug * | |||||
def revision_metadata(): | def revision_metadata(): | ||||
return dictionaries(pgsql_text(), pgsql_text()) | return dictionaries(pgsql_text(), pgsql_text()) | ||||
def revisions(): | def revisions(): | ||||
return builds( | return builds( | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |
I'd like this to be two different statement (one for draw + builds, one for evolve), for readability.