Page MenuHomeSoftware Heritage

D2739.id9781.diff
No OneTemporary

D2739.id9781.diff

diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py
--- a/swh/model/hypothesis_strategies.py
+++ b/swh/model/hypothesis_strategies.py
@@ -7,11 +7,11 @@
import datetime
from hypothesis.strategies import (
- binary, builds, characters, composite, dictionaries, from_regex,
- integers, just, lists, none, one_of, sampled_from, text, tuples,
+ binary, builds, characters, composite, dictionaries,
+ from_regex, integers, just, lists, none, one_of,
+ sampled_from, sets, text, tuples,
)
-
from .from_disk import DentryPerms
from .model import (
Person, Timestamp, TimestampWithTimezone, Origin, OriginVisit,
@@ -139,33 +139,33 @@
return one_of(present_contents(), skipped_contents())
-@composite
-def present_contents(draw):
- return draw(builds(
- Content,
- length=integers(min_value=0, max_value=2**63-1),
- sha1=sha1(),
- sha1_git=sha1_git(),
- sha256=binary(min_size=32, max_size=32),
- blake2s256=binary(min_size=32, max_size=32),
+def present_contents():
+ return builds(
+ Content.from_data,
+ binary(max_size=4096),
status=one_of(just('visible'), just('hidden')),
- data=binary(),
- ))
+ )
@composite
def skipped_contents(draw):
- return draw(builds(
- SkippedContent,
- length=integers(min_value=-1, max_value=2**63-1),
- sha1=optional(sha1()),
- sha1_git=optional(sha1_git()),
- sha256=optional(binary(min_size=32, max_size=32)),
- blake2s256=optional(binary(min_size=32, max_size=32)),
- status=just('absent'),
+ nullify_attrs = draw(
+ sets(sampled_from(['sha1', 'sha1_git', 'sha256', 'blake2s256']))
+ )
+
+ new_attrs = {
+ k: None
+ for k in nullify_attrs
+ }
+
+ ret = draw(builds(
+ SkippedContent.from_data,
+ binary(max_size=4096),
reason=pgsql_text(),
))
+ return attr.evolve(ret, **new_attrs)
+
def branch_names():
return binary(min_size=1)

File Metadata

Mime Type
text/plain
Expires
Dec 20 2024, 1:22 AM (11 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216849

Event Timeline