From 051cea3ded613218eb65935c7ea0769316e59445 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Mon, 13 Jun 2022 10:15:33 +0200 Subject: [PATCH] found bug in pytest fixture setup causing serve_test to fail (s3 backend fixture function vs s3 backend decorator fixture) --- test/conftest.py | 4 +++- test/integration_tests/serve_test.py | 27 ++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index a39a664..d8d5f5b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -92,7 +92,9 @@ def storage(client_name, bucket_name, s3_backend, docker_compose): storage.clear_bucket(bucket_name) -@pytest.fixture(params=["minio", "aws"], scope="session") +# NOTE: when this fixture is used, then serve_test fails. When instead a decorator with the same logic is used, +# serve_test passes. +@pytest.fixture(params=["minio", "aws"]) def s3_backend(request): return request.param diff --git a/test/integration_tests/serve_test.py b/test/integration_tests/serve_test.py index 87745e8..7ed8b6f 100644 --- a/test/integration_tests/serve_test.py +++ b/test/integration_tests/serve_test.py @@ -30,13 +30,13 @@ from test.utils.input import pair_data_with_queue_message "batched", [ False, - # True, + True, ], ) @pytest.mark.parametrize( "one_to_many", [ - # False, + False, True, ], ) @@ -44,14 +44,14 @@ from test.utils.input import pair_data_with_queue_message "analysis_task", [ False, - # True, + True, ], ) @pytest.mark.parametrize( "n_items", [ 1, - # 3, + 3, ], ) @pytest.mark.parametrize("n_pages", [2]) @@ -60,8 +60,8 @@ from test.utils.input import pair_data_with_queue_message "item_type", [ "string", - # "image", - # "pdf", + "image", + "pdf", ], ) @pytest.mark.parametrize( @@ -85,18 +85,17 @@ from test.utils.input import pair_data_with_queue_message "components_type", [ "test", - # "real", + "real", ], ) @pytest.mark.parametrize( "many_to_n", [ False, - # True, + True, ], ) def test_serving(server_process, bucket_name, components, targets, data_message_pairs, n_items, many_to_n): - input("before") print() storage, queue_manager, consumer = components @@ -135,8 +134,6 @@ def test_serving(server_process, bucket_name, components, targets, data_message_ # TODO: correctness of target should be validated as well, since production was become non-trivial assert sorted(outputs) == sorted(targets) - input("after") - @pytest.fixture def data_metadata_packs(input_data_items, metadata): @@ -181,10 +178,10 @@ def get_data_uploaded_by_consumer(queue_manager, storage, bucket_name): @pytest.fixture -def components(components_type, test_components, bucket_name): - # if components_type == "real": - # components = real_components - if components_type == "test": +def components(components_type, real_components, test_components, bucket_name): + if components_type == "real": + components = real_components + elif components_type == "test": components = test_components else: raise ValueError(f"Unknown component type '{components_type}'.")