Skip to content

Commit

Permalink
test: deduplicate pytest params for problem 1164
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Jan 24, 2025
1 parent f71db9d commit 6ed1195
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 100 deletions.
51 changes: 1 addition & 50 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
52 changes: 52 additions & 0 deletions tests/test_problem_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
51 changes: 1 addition & 50 deletions tests/test_pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6ed1195

Please sign in to comment.