|
|
|
@ -12,10 +12,10 @@ import ansible.plugins.filter.mathstuff as ms
|
|
|
|
|
from ansible.errors import AnsibleFilterError, AnsibleFilterTypeError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNIQUE_DATA = (([1, 3, 4, 2], sorted([1, 2, 3, 4])),
|
|
|
|
|
([1, 3, 2, 4, 2, 3], sorted([1, 2, 3, 4])),
|
|
|
|
|
(['a', 'b', 'c', 'd'], sorted(['a', 'b', 'c', 'd'])),
|
|
|
|
|
(['a', 'a', 'd', 'b', 'a', 'd', 'c', 'b'], sorted(['a', 'b', 'c', 'd'])),
|
|
|
|
|
UNIQUE_DATA = (([1, 3, 4, 2], [1, 3, 4, 2]),
|
|
|
|
|
([1, 3, 2, 4, 2, 3], [1, 3, 2, 4]),
|
|
|
|
|
(['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd']),
|
|
|
|
|
(['a', 'a', 'd', 'b', 'a', 'd', 'c', 'b'], ['a', 'd', 'b', 'c']),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
TWO_SETS_DATA = (([1, 2], [3, 4], ([], sorted([1, 2]), sorted([1, 2, 3, 4]), sorted([1, 2, 3, 4]))),
|
|
|
|
@ -29,10 +29,10 @@ env = Environment()
|
|
|
|
|
@pytest.mark.parametrize('data, expected', UNIQUE_DATA)
|
|
|
|
|
class TestUnique:
|
|
|
|
|
def test_unhashable(self, data, expected):
|
|
|
|
|
assert sorted(ms.unique(env, list(data))) == expected
|
|
|
|
|
assert ms.unique(env, list(data)) == expected
|
|
|
|
|
|
|
|
|
|
def test_hashable(self, data, expected):
|
|
|
|
|
assert sorted(ms.unique(env, tuple(data))) == expected
|
|
|
|
|
assert ms.unique(env, tuple(data)) == expected
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('dataset1, dataset2, expected', TWO_SETS_DATA)
|
|
|
|
|