diff --git a/swh/journal/tests/conftest.py b/swh/journal/tests/conftest.py --- a/swh/journal/tests/conftest.py +++ b/swh/journal/tests/conftest.py @@ -10,6 +10,7 @@ import string from confluent_kafka import Consumer +from hypothesis.strategies import one_of from subprocess import Popen from typing import Any, Dict, List, Optional, Tuple @@ -18,6 +19,7 @@ make_zookeeper_process, make_kafka_server, ZOOKEEPER_CONFIG_TEMPLATE, ) +from swh.model import hypothesis_strategies as strategies from swh.model.hashutil import hash_to_bytes @@ -75,7 +77,7 @@ 'microseconds': 0, }, 'offset': 120, - 'negative_utc': None, + 'negative_utc': False, }, { 'timestamp': { @@ -83,7 +85,7 @@ 'microseconds': 0, }, 'offset': 120, - 'negative_utc': None, + 'negative_utc': False, } ] @@ -96,7 +98,7 @@ 'author': COMMITTERS[0], 'committer_date': DATES[0], 'type': 'git', - 'directory': '\x01'*20, + 'directory': b'\x01'*20, 'synthetic': False, 'metadata': None, 'parents': [], @@ -109,7 +111,7 @@ 'author': COMMITTERS[1], 'committer_date': DATES[1], 'type': 'hg', - 'directory': '\x02'*20, + 'directory': b'\x02'*20, 'synthetic': False, 'metadata': None, 'parents': [], @@ -126,7 +128,7 @@ 'microseconds': 0, }, 'offset': 120, - 'negative_utc': None, + 'negative_utc': False, }, 'author': COMMITTERS[0], 'target_type': 'revision', @@ -262,3 +264,24 @@ yield consumer consumer.close() + + +def objects_d(): + return one_of( + strategies.origins().map( + lambda x: ('origin', x.to_dict())), + strategies.origin_visits().map( + lambda x: ('origin_visit', x.to_dict())), + strategies.snapshots().map( + lambda x: ('snapshot', x.to_dict())), + strategies.releases().map( + lambda x: ('release', x.to_dict())), + strategies.revisions().map( + lambda x: ('revision', x.to_dict())), + strategies.directories().map( + lambda x: ('directory', x.to_dict())), + strategies.skipped_contents().map( + lambda x: ('skipped_content', x.to_dict())), + strategies.present_contents().map( + lambda x: ('content', x.to_dict())), + ) diff --git a/swh/journal/tests/test_write_replay.py b/swh/journal/tests/test_write_replay.py --- a/swh/journal/tests/test_write_replay.py +++ b/swh/journal/tests/test_write_replay.py @@ -10,9 +10,7 @@ from hypothesis import given, settings, HealthCheck from hypothesis.strategies import lists -from swh.model.hypothesis_strategies import ( - object_dicts, present_contents -) +from swh.model.hypothesis_strategies import present_contents from swh.model.model import Origin from swh.storage import get_storage from swh.storage.exc import HashCollision @@ -22,7 +20,7 @@ ) from .utils import MockedJournalClient, MockedKafkaWriter - +from .conftest import objects_d storage_config = { 'cls': 'memory', @@ -56,7 +54,7 @@ return rev_or_rel -@given(lists(object_dicts(), min_size=1)) +@given(lists(objects_d(), min_size=1)) @settings(suppress_health_check=[HealthCheck.too_slow]) def test_write_replay_same_order_batches(objects): queue = []