Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hypothesis_strategies.py
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
@composite | @composite | ||||
def urls(draw): | def urls(draw): | ||||
protocol = draw(sampled_from(["git", "http", "https", "deb"])) | protocol = draw(sampled_from(["git", "http", "https", "deb"])) | ||||
domain = draw(from_regex(r"\A([a-z]([a-z0-9-]*)\.){1,3}[a-z0-9]+\Z")) | domain = draw(from_regex(r"\A([a-z]([a-z0-9-]*)\.){1,3}[a-z0-9]+\Z")) | ||||
return "%s://%s" % (protocol, domain) | return "%s://%s" % (protocol, domain) | ||||
def persons_d(): | @composite | ||||
return builds( | def persons_d(draw): | ||||
dict, fullname=binary(), email=optional(binary()), name=optional(binary()), | fullname = draw(binary()) | ||||
) | email = draw(optional(binary())) | ||||
name = draw(optional(binary())) | |||||
assume(not (len(fullname) == 32 and email is None and name is None)) | |||||
ardumont: \o/ | |||||
return dict(fullname=fullname, name=name, email=email) | |||||
def persons(): | def persons(): | ||||
return persons_d().map(Person.from_dict) | return persons_d().map(Person.from_dict) | ||||
def timestamps_d(): | def timestamps_d(): | ||||
max_seconds = datetime.datetime.max.replace( | max_seconds = datetime.datetime.max.replace( | ||||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |
\o/