Skip to content

Commit

Permalink
test: deduplicate pytest params for problem 1193
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Feb 2, 2025
1 parent faeca9c commit 10d52a4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 120 deletions.
61 changes: 1 addition & 60 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,66 +386,7 @@ def test_problem_1174(input_data, expected_data):

@pytest.mark.parametrize(
"input_data, expected_data",
[
pytest.param(
{
"trans_date": [
datetime(2023, 1, 1),
datetime(2023, 1, 15),
datetime(2023, 2, 1),
],
"state": ["approved", "pending", "approved"],
"amount": [100, 200, 300],
"country": ["US", "US", "CA"],
"id": [1, 2, 3],
},
{
"month": ["2023-01", "2023-02"],
"country": ["US", "CA"],
"trans_count": [2, 1],
"approved_count": [1, 1],
"trans_total_amount": [300, 300],
"approved_total_amount": [100, 300],
},
id="happy_path_1",
),
pytest.param(
{
"trans_date": [datetime(2023, 3, 1)],
"state": ["approved"],
"amount": [500],
"country": [None],
"id": [4],
},
{
"month": ["2023-03"],
"country": [float("nan")],
"trans_count": [1],
"approved_count": [1],
"trans_total_amount": [500],
"approved_total_amount": [500],
},
id="happy_path_null_country",
),
pytest.param(
{
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
"state": ["pending", "rejected"],
"amount": [150, 250],
"country": ["FR", "FR"],
"id": [5, 6],
},
{
"month": ["2023-04"],
"country": ["FR"],
"trans_count": [2],
"approved_count": [0],
"trans_total_amount": [400],
"approved_total_amount": [0],
},
id="edge_case_all_unapproved",
),
],
PARAMS_PROBLEM_1193,
)
def test_problem_1193(input_data, expected_data):
table = pd.DataFrame(input_data)
Expand Down
61 changes: 61 additions & 0 deletions tests/test_problem_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,67 @@
),
]

PARAMS_PROBLEM_1193 = [
pytest.param(
{
"trans_date": [
datetime(2023, 1, 1),
datetime(2023, 1, 15),
datetime(2023, 2, 1),
],
"state": ["approved", "pending", "approved"],
"amount": [100, 200, 300],
"country": ["US", "US", "CA"],
"id": [1, 2, 3],
},
{
"month": ["2023-01", "2023-02"],
"country": ["US", "CA"],
"trans_count": [2, 1],
"approved_count": [1, 1],
"trans_total_amount": [300, 300],
"approved_total_amount": [100, 300],
},
id="happy_path_1",
),
pytest.param(
{
"trans_date": [datetime(2023, 3, 1)],
"state": ["approved"],
"amount": [500],
"country": [None],
"id": [4],
},
{
"month": ["2023-03"],
"country": [None],
"trans_count": [1],
"approved_count": [1],
"trans_total_amount": [500],
"approved_total_amount": [500],
},
id="happy_path_null_country",
),
pytest.param(
{
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
"state": ["pending", "rejected"],
"amount": [150, 250],
"country": ["FR", "FR"],
"id": [5, 6],
},
{
"month": ["2023-04"],
"country": ["FR"],
"trans_count": [2],
"approved_count": [0],
"trans_total_amount": [400],
"approved_total_amount": [0],
},
id="edge_case_all_unapproved",
),
]

PARAMS_PROBLEM_1204 = [
pytest.param(
{
Expand Down
61 changes: 1 addition & 60 deletions tests/test_pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,66 +364,7 @@ def test_problem_1174(input_data, expected_data):

@pytest.mark.parametrize(
"input_data, expected_data",
[
pytest.param(
{
"trans_date": [
datetime(2023, 1, 1),
datetime(2023, 1, 15),
datetime(2023, 2, 1),
],
"state": ["approved", "pending", "approved"],
"amount": [100, 200, 300],
"country": ["US", "US", "CA"],
"id": [1, 2, 3],
},
{
"month": ["2023-01", "2023-02"],
"country": ["US", "CA"],
"trans_count": [2, 1],
"approved_count": [1, 1],
"trans_total_amount": [300, 300],
"approved_total_amount": [100, 300],
},
id="happy_path_1",
),
pytest.param(
{
"trans_date": [datetime(2023, 3, 1)],
"state": ["approved"],
"amount": [500],
"country": [None],
"id": [4],
},
{
"month": ["2023-03"],
"country": [None],
"trans_count": [1],
"approved_count": [1],
"trans_total_amount": [500],
"approved_total_amount": [500],
},
id="happy_path_null_country",
),
pytest.param(
{
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
"state": ["pending", "rejected"],
"amount": [150, 250],
"country": ["FR", "FR"],
"id": [5, 6],
},
{
"month": ["2023-04"],
"country": ["FR"],
"trans_count": [2],
"approved_count": [0],
"trans_total_amount": [400],
"approved_total_amount": [0],
},
id="edge_case_all_unapproved",
),
],
PARAMS_PROBLEM_1193,
)
def test_problem_1193(input_data, expected_data):
table = pa.Table.from_pydict(input_data)
Expand Down

0 comments on commit 10d52a4

Please sign in to comment.