Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hypothesis_strategies.py
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | def sha1_git(): | ||||
return binary(min_size=20, max_size=20) | return binary(min_size=20, max_size=20) | ||||
def sha1(): | def sha1(): | ||||
return binary(min_size=20, max_size=20) | return binary(min_size=20, max_size=20) | ||||
def aware_datetimes(): | def aware_datetimes(): | ||||
return datetimes(timezones=timezones()) | # datetimes in Software Heritage are not used for software artifacts | ||||
# (which may be much older than 2000), but only for objects like scheduler | |||||
# task runs, and origin visits, which were created by Software Heritage, | |||||
# so at least in 2015. | |||||
# We're forbidding old datetimes, because until 1956, many timezones had seconds | |||||
# in their "UTC offsets" (see | |||||
# <https://en.wikipedia.org/wiki/Time_zone#Worldwide_time_zones>), which is not | |||||
# encodable in ISO8601; and we need our datetimes to be ISO8601-encodable in the | |||||
# RPC protocol | |||||
min_value = datetime.datetime(2000, 1, 1, 0, 0, 0) | |||||
return datetimes(min_value=min_value, timezones=timezones()) | |||||
@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) | ||||
▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines |