diff --git a/PKG-INFO b/PKG-INFO index d32ec1c75daab61a182ea73fadc761ef17c01594..f0a6d7d6146ff5af350c267bb615f22127d353bf 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.0.55 +Version: 0.0.56 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 d32ec1c75daab61a182ea73fadc761ef17c01594..f0a6d7d6146ff5af350c267bb615f22127d353bf 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.55 +Version: 0.0.56 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 8d3923c76536fe7f0888b7e8be14693f9002f6a9..e6d830aa111f1c59d8fcba255326b463534b8dd6 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -26,6 +26,10 @@ pgsql_alphabet = characters( blacklist_characters=['\u0000']) # postgresql does not like these +def optional(strategy): + return one_of(none(), strategy) + + def pgsql_text(): return text(alphabet=pgsql_alphabet) @@ -81,7 +85,8 @@ def origin_visits(): visit=integers(0, 1000), origin=urls(), status=sampled_from(['ongoing', 'full', 'partial']), - type=pgsql_text()) + type=pgsql_text(), + snapshot=optional(sha1_git())) @composite @@ -148,9 +153,6 @@ def present_contents(draw): @composite def skipped_contents(draw): - def optional(strategy): - return one_of(none(), strategy) - return draw(builds( SkippedContent, length=integers(min_value=-1, max_value=2**63-1), diff --git a/swh/model/model.py b/swh/model/model.py index 2a2eda27e398bc3c38242f620064f0e27167a048..512824d60a1ab05254dbb7649d6f0ba2ffc54bd6 100644 --- a/swh/model/model.py +++ b/swh/model/model.py @@ -149,7 +149,7 @@ class OriginVisit(BaseModel): type=str, validator=attr.validators.in_(['ongoing', 'full', 'partial'])) type = attr.ib(type=str) - snapshot = attr.ib(type=Sha1Git) + snapshot = attr.ib(type=Optional[Sha1Git]) metadata = attr.ib(type=Optional[Dict[str, object]], default=None) diff --git a/version.txt b/version.txt index 8c5743b4feeccce19dee1a30d4bdd0e9413b8064..fc9120ade4f5e100bf204c973fc37610cb316167 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.0.55-0-g73053a6 \ No newline at end of file +v0.0.56-0-gfcfbd4d \ No newline at end of file