From 6ed1195b3f80f96ef614b2a1b2e979b54453ccee Mon Sep 17 00:00:00 2001 From: Tyler White <50381805+IndexSeek@users.noreply.github.com> Date: Fri, 24 Jan 2025 23:40:03 +0000 Subject: [PATCH] test: deduplicate pytest params for problem 1164 --- tests/test_pandas.py | 51 +---------------------------------- tests/test_problem_params.py | 52 ++++++++++++++++++++++++++++++++++++ tests/test_pyarrow.py | 51 +---------------------------------- 3 files changed, 54 insertions(+), 100 deletions(-) diff --git a/tests/test_pandas.py b/tests/test_pandas.py index 19eb66b..0277eae 100644 --- a/tests/test_pandas.py +++ b/tests/test_pandas.py @@ -396,56 +396,7 @@ def test_problem_1148(input_data, expected_data): @pytest.mark.parametrize( "input_data, expected_data", - [ - pytest.param( - { - "product_id": [1, 1, 2], - "change_date": [ - datetime(2019, 8, 15), - datetime(2019, 8, 16), - datetime(2019, 8, 17), - ], - "new_price": [100, 110, 120], - }, - {"product_id": [1, 2], "price": [110, 10]}, - id="happy-path", - ), - pytest.param( - { - "product_id": [1, 2], - "change_date": [ - datetime(2019, 8, 17), - datetime(2019, 8, 18), - ], - "new_price": [100, 110], - }, - {"product_id": [1, 2], "price": [10, 10]}, - id="no-products-before-cutoff", - ), - pytest.param( - { - "product_id": [1], - "change_date": [ - datetime(2019, 8, 18), - ], - "new_price": [20], - }, - {"product_id": [1], "price": [10]}, - id="single-product-after-cutoff", - ), - pytest.param( - { - "product_id": [1, 2], - "new_price": [100, 100], - "change_date": [ - datetime(2019, 8, 1), - datetime(2019, 8, 2), - ], - }, - {"product_id": [1, 2], "price": [100, 100]}, - id="all-products-before-cutoff", - ), - ], + PARAMS_PROBLEM_1164, ) def test_problem_1164(input_data, expected_data): table = pd.DataFrame(input_data) diff --git a/tests/test_problem_params.py b/tests/test_problem_params.py index 1dfab87..dbd47d5 100644 --- a/tests/test_problem_params.py +++ b/tests/test_problem_params.py @@ -838,6 +838,58 @@ ), ] + +PARAMS_PROBLEM_1164 = [ + pytest.param( + { + "product_id": [1, 1, 2], + "change_date": [ + datetime(2019, 8, 15), + datetime(2019, 8, 16), + datetime(2019, 8, 17), + ], + "new_price": [100, 110, 120], + }, + {"product_id": [1, 2], "price": [110, 10]}, + id="happy-path", + ), + pytest.param( + { + "product_id": [1, 2], + "change_date": [ + datetime(2019, 8, 17), + datetime(2019, 8, 18), + ], + "new_price": [100, 110], + }, + {"product_id": [1, 2], "price": [10, 10]}, + id="no-products-before-cutoff", + ), + pytest.param( + { + "product_id": [1], + "change_date": [ + datetime(2019, 8, 18), + ], + "new_price": [20], + }, + {"product_id": [1], "price": [10]}, + id="single-product-after-cutoff", + ), + pytest.param( + { + "product_id": [1, 2], + "new_price": [100, 100], + "change_date": [ + datetime(2019, 8, 1), + datetime(2019, 8, 2), + ], + }, + {"product_id": [1, 2], "price": [100, 100]}, + id="all-products-before-cutoff", + ), +] + PARAMS_PROBLEM_1204 = [ pytest.param( { diff --git a/tests/test_pyarrow.py b/tests/test_pyarrow.py index a423580..46b2ac8 100644 --- a/tests/test_pyarrow.py +++ b/tests/test_pyarrow.py @@ -378,56 +378,7 @@ def test_problem_1148(input_data, expected_data): @pytest.mark.parametrize( "input_data, expected_data", - [ - pytest.param( - { - "product_id": [1, 1, 2], - "change_date": [ - datetime(2019, 8, 15), - datetime(2019, 8, 16), - datetime(2019, 8, 17), - ], - "new_price": [100, 110, 120], - }, - {"product_id": [1, 2], "price": [110, 10]}, - id="happy-path", - ), - pytest.param( - { - "product_id": [1, 2], - "change_date": [ - datetime(2019, 8, 17), - datetime(2019, 8, 18), - ], - "new_price": [100, 110], - }, - {"product_id": [1, 2], "price": [10, 10]}, - id="no-products-before-cutoff", - ), - pytest.param( - { - "product_id": [1], - "change_date": [ - datetime(2019, 8, 18), - ], - "new_price": [20], - }, - {"product_id": [1], "price": [10]}, - id="single-product-after-cutoff", - ), - pytest.param( - { - "product_id": [1, 2], - "new_price": [100, 100], - "change_date": [ - datetime(2019, 8, 1), - datetime(2019, 8, 2), - ], - }, - {"product_id": [1, 2], "price": [100, 100]}, - id="all-products-before-cutoff", - ), - ], + PARAMS_PROBLEM_1164, ) def test_problem_1164(input_data, expected_data): input_table = pa.Table.from_pydict(input_data)