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 @@ -215,7 +215,7 @@ target = sha1_git() metadata = optional(revision_metadata()) - return draw( + d = draw( one_of( builds( dict, @@ -242,6 +242,11 @@ ) ) + raw_manifest = draw(optional(binary())) + if raw_manifest: + d["raw_manifest"] = raw_manifest + return d + def releases(): return releases_d().map(Release.from_dict) @@ -256,23 +261,31 @@ ).map(tuple) -def revisions_d(): - return builds( - dict, - message=optional(binary()), - synthetic=booleans(), - author=persons_d(), - committer=persons_d(), - date=timestamps_with_timezone_d(), - committer_date=timestamps_with_timezone_d(), - parents=tuples(sha1_git()), - directory=sha1_git(), - type=sampled_from([x.value for x in RevisionType]), - metadata=optional(revision_metadata()), - extra_headers=extra_headers(), +@composite +def revisions_d(draw): + d = draw( + builds( + dict, + message=optional(binary()), + synthetic=booleans(), + author=persons_d(), + committer=persons_d(), + date=timestamps_with_timezone_d(), + committer_date=timestamps_with_timezone_d(), + parents=tuples(sha1_git()), + directory=sha1_git(), + type=sampled_from([x.value for x in RevisionType]), + metadata=optional(revision_metadata()), + extra_headers=extra_headers(), + ) ) # TODO: metadata['extra_headers'] can have binary keys and values + raw_manifest = draw(optional(binary())) + if raw_manifest: + d["raw_manifest"] = raw_manifest + return d + def revisions(): return revisions_d().map(Revision.from_dict) @@ -313,8 +326,14 @@ return directory_entries_d().map(DirectoryEntry) -def directories_d(): - return builds(dict, entries=tuples(directory_entries_d())) +@composite +def directories_d(draw): + d = draw(builds(dict, entries=tuples(directory_entries_d()))) + + raw_manifest = draw(optional(binary())) + if raw_manifest: + d["raw_manifest"] = raw_manifest + return d def directories():