Skip to content

Commit

Permalink
test: deduplicate pytest params for problem 185
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Jan 5, 2025
1 parent 1ffb23f commit f48953c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 94 deletions.
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ unfixable = []
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.per-file-ignores]
"problems/*.py" = ["F405"]
"problems/datasets.py" = ["D103"]
"problems/utils.py" = ["D"]
"tests/*" = ["D", "F403", "F405"]
Expand Down
48 changes: 1 addition & 47 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,53 +33,7 @@ def test_problem_180(input_data, expected_data):

@pytest.mark.parametrize(
"input_data_1, input_data_2, expected_data",
[
pytest.param(
{
"id": [1, 2, 3, 4, 5, 6, 7],
"name": ["Joe", "Henry", "Sam", "Max", "Janet", "Randy", "Will"],
"salary": [85000, 80000, 60000, 90000, 69000, 85000, 70000],
"departmentId": [1, 2, 2, 1, 1, 1, 1],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "Sales", "Sales", "IT", "IT", "IT"],
"Employee": ["Joe", "Henry", "Sam", "Max", "Randy", "Will"],
"Salary": [85000, 80000, 60000, 90000, 85000, 70000],
},
id="happy_path_basic",
),
pytest.param(
{
"id": [1, 2, 3],
"name": ["Alice", "Bob", "Charlie"],
"salary": [60000, 75000, 80000],
"departmentId": [1, 2, 1],
},
{"id": [1, 2], "name": ["HR", "Finance"]},
{
"Department": ["HR", "Finance", "HR"],
"Employee": ["Alice", "Bob", "Charlie"],
"Salary": [60000, 75000, 80000],
},
id="single_employee_multiple_departments",
),
pytest.param(
{
"id": [1, 2, 3, 4],
"name": ["Alice", "Alice", "Bob", "Charlie"],
"salary": [70000, 80000, 75000, 90000],
"departmentId": [1, 1, 2, 2],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "IT", "Sales", "Sales"],
"Employee": ["Alice", "Alice", "Bob", "Charlie"],
"Salary": [70000, 80000, 75000, 90000],
},
id="duplicate_employees_different_salaries",
),
],
PARAMS_PROBLEM_185,
)
def test_problem_185(input_data_1, input_data_2, expected_data):
table_1 = pd.DataFrame(input_data_1)
Expand Down
48 changes: 48 additions & 0 deletions tests/test_problem_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,51 @@
id="empty_table",
),
]

PARAMS_PROBLEM_185 = [
pytest.param(
{
"id": [1, 2, 3, 4, 5, 6, 7],
"name": ["Joe", "Henry", "Sam", "Max", "Janet", "Randy", "Will"],
"salary": [85000, 80000, 60000, 90000, 69000, 85000, 70000],
"departmentId": [1, 2, 2, 1, 1, 1, 1],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "Sales", "Sales", "IT", "IT", "IT"],
"Employee": ["Joe", "Henry", "Sam", "Max", "Randy", "Will"],
"Salary": [85000, 80000, 60000, 90000, 85000, 70000],
},
id="happy_path_basic",
),
pytest.param(
{
"id": [1, 2, 3],
"name": ["Alice", "Bob", "Charlie"],
"salary": [60000, 75000, 80000],
"departmentId": [1, 2, 1],
},
{"id": [1, 2], "name": ["HR", "Finance"]},
{
"Department": ["HR", "Finance", "HR"],
"Employee": ["Alice", "Bob", "Charlie"],
"Salary": [60000, 75000, 80000],
},
id="single_employee_multiple_departments",
),
pytest.param(
{
"id": [1, 2, 3, 4],
"name": ["Alice", "Alice", "Bob", "Charlie"],
"salary": [70000, 80000, 75000, 90000],
"departmentId": [1, 1, 2, 2],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "IT", "Sales", "Sales"],
"Employee": ["Alice", "Alice", "Bob", "Charlie"],
"Salary": [70000, 80000, 75000, 90000],
},
id="duplicate_employees_different_salaries",
),
]
48 changes: 1 addition & 47 deletions tests/test_pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,53 +35,7 @@ def test_problem_180(input_data, expected_data):

@pytest.mark.parametrize(
"input_data_1, input_data_2, expected_data",
[
pytest.param(
{
"id": [1, 2, 3, 4, 5, 6, 7],
"name": ["Joe", "Henry", "Sam", "Max", "Janet", "Randy", "Will"],
"salary": [85000, 80000, 60000, 90000, 69000, 85000, 70000],
"departmentId": [1, 2, 2, 1, 1, 1, 1],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "Sales", "Sales", "IT", "IT", "IT"],
"Employee": ["Joe", "Henry", "Sam", "Max", "Randy", "Will"],
"Salary": [85000, 80000, 60000, 90000, 85000, 70000],
},
id="happy_path_basic",
),
pytest.param(
{
"id": [1, 2, 3],
"name": ["Alice", "Bob", "Charlie"],
"salary": [60000, 75000, 80000],
"departmentId": [1, 2, 1],
},
{"id": [1, 2], "name": ["HR", "Finance"]},
{
"Department": ["HR", "Finance", "HR"],
"Employee": ["Alice", "Bob", "Charlie"],
"Salary": [60000, 75000, 80000],
},
id="single_employee_multiple_departments",
),
pytest.param(
{
"id": [1, 2, 3, 4],
"name": ["Alice", "Alice", "Bob", "Charlie"],
"salary": [70000, 80000, 75000, 90000],
"departmentId": [1, 1, 2, 2],
},
{"id": [1, 2], "name": ["IT", "Sales"]},
{
"Department": ["IT", "IT", "Sales", "Sales"],
"Employee": ["Alice", "Alice", "Bob", "Charlie"],
"Salary": [70000, 80000, 75000, 90000],
},
id="duplicate_employees_different_salaries",
),
],
PARAMS_PROBLEM_185,
)
def test_problem_185(input_data_1, input_data_2, expected_data):
table_1 = pa.Table.from_pydict(input_data_1)
Expand Down

0 comments on commit f48953c

Please sign in to comment.