diff --git a/PKG-INFO b/PKG-INFO index e8c829eb88912a0ce80ee46924c248c261085a82..f1120edf560986917c20ffbade9e6640ca056336 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.1.0 +Version: 0.1.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/swh.model.egg-info/PKG-INFO b/swh.model.egg-info/PKG-INFO index e8c829eb88912a0ce80ee46924c248c261085a82..f1120edf560986917c20ffbade9e6640ca056336 100644 --- a/swh.model.egg-info/PKG-INFO +++ b/swh.model.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.1.0 +Version: 0.1.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py index d193852283d94e0c365a54dab64f37adda1315cd..448487a8ea2e1e2bc79a51529c64402f17cccdd6 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -72,7 +72,17 @@ def sha1(): 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 diff --git a/swh/model/tests/test_hypothesis_strategies.py b/swh/model/tests/test_hypothesis_strategies.py index 2df2d7a21b48ad68f4fb425208c92a374fc19197..1622b3c71ba47542f4cec845d3a2094f3f152dfd 100644 --- a/swh/model/tests/test_hypothesis_strategies.py +++ b/swh/model/tests/test_hypothesis_strategies.py @@ -6,10 +6,12 @@ import datetime import attr +import iso8601 from hypothesis import given, settings from swh.model.hashutil import DEFAULT_ALGORITHMS from swh.model.hypothesis_strategies import ( + aware_datetimes, objects, object_dicts, contents, @@ -93,6 +95,14 @@ def test_dicts_generation(obj_type_and_obj): assert branch is None or branch["target_type"] in target_types +@given(aware_datetimes()) +def test_datetimes(dt): + # Checks this doesn't raise an error, eg. about seconds in the TZ offset + iso8601.parse_date(dt.isoformat()) + + assert dt.tzinfo is not None + + @given(object_dicts(split_content=False)) def test_dicts_generation_merged_content(obj_type_and_obj): # we should never generate a "skipped_content" here diff --git a/version.txt b/version.txt index 2cd1e9464db49d4ad68c155ea77f9612d4d39e48..8019930dbc7fb6e043f89728e2f895f10b09ad3b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.1.0-0-g9f5d266 \ No newline at end of file +v0.1.1-0-g091498e \ No newline at end of file