diff --git a/PKG-INFO b/PKG-INFO index fbaf0f3f049f06af4d297d2075c16f978230cfdc..e8c829eb88912a0ce80ee46924c248c261085a82 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.0.69 +Version: 0.1.0 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers @@ -9,6 +9,7 @@ License: UNKNOWN Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-model +Project-URL: Documentation, https://docs.softwareheritage.org/devel/swh-model/ Description: swh-model ========= diff --git a/setup.py b/setup.py index 4955e1ddda62b4777554c38b74b4e5ab23bc3767..f2432ac311654135b4c0851fe322f892cd1121d9 100755 --- a/setup.py +++ b/setup.py @@ -74,5 +74,6 @@ setup( "Bug Reports": "https://forge.softwareheritage.org/maniphest", "Funding": "https://www.softwareheritage.org/donate", "Source": "https://forge.softwareheritage.org/source/swh-model", + "Documentation": "https://docs.softwareheritage.org/devel/swh-model/", }, ) diff --git a/swh.model.egg-info/PKG-INFO b/swh.model.egg-info/PKG-INFO index fbaf0f3f049f06af4d297d2075c16f978230cfdc..e8c829eb88912a0ce80ee46924c248c261085a82 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.0.69 +Version: 0.1.0 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers @@ -9,6 +9,7 @@ License: UNKNOWN Project-URL: Bug Reports, https://forge.softwareheritage.org/maniphest Project-URL: Funding, https://www.softwareheritage.org/donate Project-URL: Source, https://forge.softwareheritage.org/source/swh-model +Project-URL: Documentation, https://docs.softwareheritage.org/devel/swh-model/ Description: swh-model ========= diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py index 1940fa4432d9286fb3213857b2c18829f1e3c26b..d193852283d94e0c365a54dab64f37adda1315cd 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -6,6 +6,7 @@ import datetime from hypothesis import assume +from hypothesis.extra.dateutil import timezones from hypothesis.strategies import ( binary, booleans, @@ -70,6 +71,10 @@ def sha1(): return binary(min_size=20, max_size=20) +def aware_datetimes(): + return datetimes(timezones=timezones()) + + @composite def urls(draw): protocol = draw(sampled_from(["git", "http", "https", "deb"])) @@ -138,7 +143,7 @@ def origin_visits_d(): dict, visit=integers(0, 1000), origin=urls(), - date=datetimes(), + date=aware_datetimes(), status=sampled_from(["ongoing", "full", "partial"]), type=pgsql_text(), snapshot=optional(sha1_git()), @@ -159,7 +164,7 @@ def origin_visit_statuses_d(): visit=integers(0, 1000), origin=urls(), status=sampled_from(["ongoing", "full", "partial"]), - date=datetimes(), + date=aware_datetimes(), snapshot=optional(sha1_git()), metadata=one_of(none(), metadata_dicts()), ) @@ -268,7 +273,7 @@ def present_contents_d(): return builds( dict, data=binary(max_size=4096), - ctime=optional(datetimes()), + ctime=optional(aware_datetimes()), status=one_of(just("visible"), just("hidden")), ) @@ -288,7 +293,7 @@ def skipped_contents_d(draw): result[k] = None result["reason"] = draw(pgsql_text()) result["status"] = "absent" - result["ctime"] = draw(optional(datetimes())) + result["ctime"] = draw(optional(aware_datetimes())) return result diff --git a/swh/model/tests/test_hypothesis_strategies.py b/swh/model/tests/test_hypothesis_strategies.py index d3ac5ef42053e7e5c4dcc2760ec6e1147ae12962..2df2d7a21b48ad68f4fb425208c92a374fc19197 100644 --- a/swh/model/tests/test_hypothesis_strategies.py +++ b/swh/model/tests/test_hypothesis_strategies.py @@ -9,7 +9,14 @@ import attr from hypothesis import given, settings from swh.model.hashutil import DEFAULT_ALGORITHMS -from swh.model.hypothesis_strategies import objects, object_dicts, snapshots +from swh.model.hypothesis_strategies import ( + objects, + object_dicts, + contents, + skipped_contents, + snapshots, + origin_visits, +) from swh.model.model import TargetType @@ -125,6 +132,16 @@ def test_model_to_dicts(obj_type_and_obj): assert branch is None or branch["target_type"] in target_types +@given(contents()) +def test_content_aware_datetime(cont): + assert cont.ctime is None or cont.ctime.tzinfo is not None + + +@given(skipped_contents()) +def test_skipped_content_aware_datetime(cont): + assert cont.ctime is None or cont.ctime.tzinfo is not None + + _min_snp_size = 10 _max_snp_size = 100 @@ -164,3 +181,8 @@ def test_snapshots_strategy(snapshot): @settings(max_examples=1) def test_snapshots_strategy_fixed_size(snapshot): assert len(snapshot.branches) == _min_snp_size + + +@given(origin_visits()) +def test_origin_visit_aware_datetime(visit): + assert visit.date.tzinfo is not None diff --git a/version.txt b/version.txt index 844832a0233c8ebc515e9fda4cec28889e8ee836..2cd1e9464db49d4ad68c155ea77f9612d4d39e48 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.0.69-0-gf97d216 \ No newline at end of file +v0.1.0-0-g9f5d266 \ No newline at end of file