Skip to content

Commit 10d52a4

Browse files
committed
test: deduplicate pytest params for problem 1193
1 parent faeca9c commit 10d52a4

File tree

3 files changed

+63
-120
lines changed

3 files changed

+63
-120
lines changed

tests/test_pandas.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -386,66 +386,7 @@ def test_problem_1174(input_data, expected_data):
386386

387387
@pytest.mark.parametrize(
388388
"input_data, expected_data",
389-
[
390-
pytest.param(
391-
{
392-
"trans_date": [
393-
datetime(2023, 1, 1),
394-
datetime(2023, 1, 15),
395-
datetime(2023, 2, 1),
396-
],
397-
"state": ["approved", "pending", "approved"],
398-
"amount": [100, 200, 300],
399-
"country": ["US", "US", "CA"],
400-
"id": [1, 2, 3],
401-
},
402-
{
403-
"month": ["2023-01", "2023-02"],
404-
"country": ["US", "CA"],
405-
"trans_count": [2, 1],
406-
"approved_count": [1, 1],
407-
"trans_total_amount": [300, 300],
408-
"approved_total_amount": [100, 300],
409-
},
410-
id="happy_path_1",
411-
),
412-
pytest.param(
413-
{
414-
"trans_date": [datetime(2023, 3, 1)],
415-
"state": ["approved"],
416-
"amount": [500],
417-
"country": [None],
418-
"id": [4],
419-
},
420-
{
421-
"month": ["2023-03"],
422-
"country": [float("nan")],
423-
"trans_count": [1],
424-
"approved_count": [1],
425-
"trans_total_amount": [500],
426-
"approved_total_amount": [500],
427-
},
428-
id="happy_path_null_country",
429-
),
430-
pytest.param(
431-
{
432-
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
433-
"state": ["pending", "rejected"],
434-
"amount": [150, 250],
435-
"country": ["FR", "FR"],
436-
"id": [5, 6],
437-
},
438-
{
439-
"month": ["2023-04"],
440-
"country": ["FR"],
441-
"trans_count": [2],
442-
"approved_count": [0],
443-
"trans_total_amount": [400],
444-
"approved_total_amount": [0],
445-
},
446-
id="edge_case_all_unapproved",
447-
),
448-
],
389+
PARAMS_PROBLEM_1193,
449390
)
450391
def test_problem_1193(input_data, expected_data):
451392
table = pd.DataFrame(input_data)

tests/test_problem_params.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,67 @@
977977
),
978978
]
979979

980+
PARAMS_PROBLEM_1193 = [
981+
pytest.param(
982+
{
983+
"trans_date": [
984+
datetime(2023, 1, 1),
985+
datetime(2023, 1, 15),
986+
datetime(2023, 2, 1),
987+
],
988+
"state": ["approved", "pending", "approved"],
989+
"amount": [100, 200, 300],
990+
"country": ["US", "US", "CA"],
991+
"id": [1, 2, 3],
992+
},
993+
{
994+
"month": ["2023-01", "2023-02"],
995+
"country": ["US", "CA"],
996+
"trans_count": [2, 1],
997+
"approved_count": [1, 1],
998+
"trans_total_amount": [300, 300],
999+
"approved_total_amount": [100, 300],
1000+
},
1001+
id="happy_path_1",
1002+
),
1003+
pytest.param(
1004+
{
1005+
"trans_date": [datetime(2023, 3, 1)],
1006+
"state": ["approved"],
1007+
"amount": [500],
1008+
"country": [None],
1009+
"id": [4],
1010+
},
1011+
{
1012+
"month": ["2023-03"],
1013+
"country": [None],
1014+
"trans_count": [1],
1015+
"approved_count": [1],
1016+
"trans_total_amount": [500],
1017+
"approved_total_amount": [500],
1018+
},
1019+
id="happy_path_null_country",
1020+
),
1021+
pytest.param(
1022+
{
1023+
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
1024+
"state": ["pending", "rejected"],
1025+
"amount": [150, 250],
1026+
"country": ["FR", "FR"],
1027+
"id": [5, 6],
1028+
},
1029+
{
1030+
"month": ["2023-04"],
1031+
"country": ["FR"],
1032+
"trans_count": [2],
1033+
"approved_count": [0],
1034+
"trans_total_amount": [400],
1035+
"approved_total_amount": [0],
1036+
},
1037+
id="edge_case_all_unapproved",
1038+
),
1039+
]
1040+
9801041
PARAMS_PROBLEM_1204 = [
9811042
pytest.param(
9821043
{

tests/test_pyarrow.py

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -364,66 +364,7 @@ def test_problem_1174(input_data, expected_data):
364364

365365
@pytest.mark.parametrize(
366366
"input_data, expected_data",
367-
[
368-
pytest.param(
369-
{
370-
"trans_date": [
371-
datetime(2023, 1, 1),
372-
datetime(2023, 1, 15),
373-
datetime(2023, 2, 1),
374-
],
375-
"state": ["approved", "pending", "approved"],
376-
"amount": [100, 200, 300],
377-
"country": ["US", "US", "CA"],
378-
"id": [1, 2, 3],
379-
},
380-
{
381-
"month": ["2023-01", "2023-02"],
382-
"country": ["US", "CA"],
383-
"trans_count": [2, 1],
384-
"approved_count": [1, 1],
385-
"trans_total_amount": [300, 300],
386-
"approved_total_amount": [100, 300],
387-
},
388-
id="happy_path_1",
389-
),
390-
pytest.param(
391-
{
392-
"trans_date": [datetime(2023, 3, 1)],
393-
"state": ["approved"],
394-
"amount": [500],
395-
"country": [None],
396-
"id": [4],
397-
},
398-
{
399-
"month": ["2023-03"],
400-
"country": [None],
401-
"trans_count": [1],
402-
"approved_count": [1],
403-
"trans_total_amount": [500],
404-
"approved_total_amount": [500],
405-
},
406-
id="happy_path_null_country",
407-
),
408-
pytest.param(
409-
{
410-
"trans_date": [datetime(2023, 4, 1), datetime(2023, 4, 2)],
411-
"state": ["pending", "rejected"],
412-
"amount": [150, 250],
413-
"country": ["FR", "FR"],
414-
"id": [5, 6],
415-
},
416-
{
417-
"month": ["2023-04"],
418-
"country": ["FR"],
419-
"trans_count": [2],
420-
"approved_count": [0],
421-
"trans_total_amount": [400],
422-
"approved_total_amount": [0],
423-
},
424-
id="edge_case_all_unapproved",
425-
),
426-
],
367+
PARAMS_PROBLEM_1193,
427368
)
428369
def test_problem_1193(input_data, expected_data):
429370
table = pa.Table.from_pydict(input_data)

0 commit comments

Comments
 (0)