Skip to content
Snippets Groups Projects
Commit ca7e9d20 authored by David Douard's avatar David Douard
Browse files

test: reimplement a local version of 'object_dicts' with 'skipped_content'

This also makes it easier to be compatible with current version of swh.model
and the next version (with runtime type validation in the model).
parent cd048505
No related branches found
No related tags found
1 merge request!141test: ensure tests are compatible with next swh.model release
......@@ -10,6 +10,7 @@ import random
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 @@ from pytest_kafka import (
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
......@@ -262,3 +264,24 @@ def consumer(
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())),
)
......@@ -10,9 +10,7 @@ import attr
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 swh.journal.replay import (
)
from .utils import MockedJournalClient, MockedKafkaWriter
from .conftest import objects_d
storage_config = {
'cls': 'memory',
......@@ -56,7 +54,7 @@ def empty_person_name_email(rev_or_rel):
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 = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment