introduce flag to distinguish between server side tests and complete integration tests

This commit is contained in:
Julius Unverfehrt 2022-06-14 11:56:47 +02:00
parent d8b5be9e72
commit bb7e631f91
3 changed files with 19 additions and 8 deletions

View File

@ -82,7 +82,7 @@ def strings_to_bytes(strings):
@pytest.fixture
def targets(data_message_pairs, input_data_items, operation, metadata):
def targets(data_message_pairs, input_data_items, operation, metadata, server_side_test):
"""TODO: this has become super wonky"""
metadata = [{**m1, **m2} for m1, m2 in zip(lmap(second, data_message_pairs), metadata)]
@ -94,7 +94,9 @@ def targets(data_message_pairs, input_data_items, operation, metadata):
try:
response_data, response_metadata = zip(*map(unpack, flatten(starmap(op, zip(input_data_items, metadata)))))
queue_message_keys = [*second(first(pair_data_with_queue_message([b""]))).keys(), "id"]
queue_message_keys = ["id"] * (not server_side_test) + [
*second(first(pair_data_with_queue_message([b""]))).keys()
]
response_metadata = lmap(partial(omit, keys=queue_message_keys), response_metadata)
expected = lzip(response_data, response_metadata)

View File

@ -61,13 +61,16 @@ def operation_conditionally_batched(operation, batched):
@pytest.fixture
def operation(core_operation):
def operation(core_operation, server_side_test):
auto_counter = Counter()
def auto_count(metadata):
idnt = itemgetter("dossierId", "fileId")(metadata)
auto_counter[idnt] += 1
return {**metadata, "id": auto_counter[idnt]} if "id" not in metadata else metadata
if not server_side_test:
idnt = itemgetter("dossierId", "fileId")(metadata)
auto_counter[idnt] += 1
return {**metadata, "id": auto_counter[idnt]} if "id" not in metadata else metadata
else:
return metadata
def op(data, metadata):
assert isinstance(metadata, dict)
@ -85,6 +88,11 @@ def operation(core_operation):
return op
@pytest.fixture(params=[False])
def server_side_test(request):
return request.param
@pytest.fixture
def core_operation(item_type, one_to_many, analysis_task):
def duplicate(string: bytes, metadata):

View File

@ -22,14 +22,15 @@ def test_mock_pipeline():
data = [1, 2, 3]
f, g, h, u = map(lift, [lambda x: x ** 2, lambda x: x + 2, lambda x: x / 2, lambda x: x])
f, g, h, u = map(lift, [lambda x: x**2, lambda x: x + 2, lambda x: x / 2, lambda x: x])
pipeline = ClientPipeline(f, g, h, u)
assert list(pipeline(data)) == list(rcompose(f, g, h, u)(data))
@pytest.mark.parametrize("client_pipeline_type", ["rest", "basic"])
@pytest.mark.parametrize("client_pipeline_type", ["basic", "rest"])
@pytest.mark.parametrize("server_side_test", [True])
def test_pipeline(core_operation, client_pipeline, input_data_items, metadata, targets, n_items):
assert core_operation is not Nothing