You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
1 year ago
|
import pandas as pd
|
||
|
import pytest
|
||
|
|
||
|
|
||
|
@pytest.fixture()
|
||
|
def example_data():
|
||
|
return pd.DataFrame({"A": [1, 2, 2], "B": [3, 4, 3], "C": ["x", "y", "z"]})
|
||
|
|
||
|
|
||
|
def test_split_uniques_one_column(example_data):
|
||
|
from conda_helpers import iter_uniques
|
||
|
|
||
|
result = list(iter_uniques(example_data, "A"))
|
||
|
|
||
|
assert len(result) == 2
|
||
|
assert isinstance(result[0], tuple)
|
||
|
|
||
|
a_value, data = result[0]
|
||
|
assert a_value == 1
|
||
|
assert list(data["C"]) == ["x"]
|
||
|
|
||
|
a_value, data = result[1]
|
||
|
assert a_value == 2
|
||
|
assert list(data["C"]) == ["y", "z"]
|
||
|
|
||
|
|
||
|
def test_split_uniques_multiple_columns(example_data):
|
||
|
from conda_helpers import iter_uniques
|
||
|
|
||
|
result = list(iter_uniques(example_data, "B", "A"))
|
||
|
|
||
|
assert len(result) == 3
|
||
|
assert isinstance(result[0], tuple)
|
||
|
|
||
|
b_value, a_value, data = result[0]
|
||
|
assert b_value == 3
|
||
|
assert a_value == 1
|
||
|
assert list(data["C"]) == ["x"]
|
||
|
|
||
|
b_value, a_value, data = result[1]
|
||
|
assert b_value == 3
|
||
|
assert a_value == 2
|
||
|
assert list(data["C"]) == ["z"]
|
||
|
|
||
|
b_value, a_value, data = result[2]
|
||
|
assert b_value == 4
|
||
|
assert a_value == 2
|
||
|
assert list(data["C"]) == ["y"]
|