Some simple tools for working with parsed Sensospot data.
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.
 
 

50 lines
1.1 KiB

import pytest
@pytest.mark.parametrize(
"provided, expected",
[
("abc", ["abc"]),
(tuple("abc"), ["a", "b", "c"]),
({"a": 1, "b": 2}, ["a", "b"]),
(1, [1]),
],
)
def test_helpers_ensure_list(provided, expected):
from sensospot_tools.helpers import ensure_list
result = ensure_list(provided)
assert result == expected
@pytest.mark.parametrize(
"arguments",
[
("A",),
("A", "B"),
("B", "C", "D"),
(["A"], "B", ["C", "D"]),
],
)
def test_helpers_check_columns_exist_ok(arguments):
import pandas
from sensospot_tools.helpers import check_columns_exist
columns = ["A", "B", "C", "D"]
data = pandas.DataFrame({c: [] for c in columns})
assert check_columns_exist(data, *arguments) is True
def test_helpers_check_columns_exist_raises_error_on_wrong_column():
import pandas
from sensospot_tools.helpers import check_columns_exist
columns = ["A", "B", "C", "D"]
data = pandas.DataFrame({c: [] for c in columns})
with pytest.raises(KeyError):
check_columns_exist(data, "DOES NOT EXIST")