Skip to content

Commit

Permalink
test: Limit sort to Keys only
Browse files Browse the repository at this point in the history
  • Loading branch information
harrtho committed Nov 17, 2023
1 parent 343f6dd commit 4114df7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_workflow_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""Unit tests for :meth:`workflow.Workflow.filter`."""

import pytest

from workflow.workflow import (MATCH_ALL, MATCH_ALLCHARS, MATCH_ATOM,
MATCH_CAPITALS, MATCH_INITIALS_CONTAIN,
MATCH_INITIALS_STARTSWITH, MATCH_STARTSWITH,
Expand Down Expand Up @@ -202,5 +203,24 @@ def test_punctuation(wf):
assert wf.dumbify_punctuation(input) == output


def test_filter_sort_keys_only(wf):
"""Filter: identical items, not sortable data"""
data = [
{'key': 'keyA', 'value': 'a1'},
{'key': 'keyA', 'value': 'a2'},
{'key': 'keyB', 'value': 'b'},
{'key': 'keyC', 'value': 'c'}
]
results = wf.filter(
"key",
data,
key=lambda x: x["key"],
)

for index, output in enumerate(data):
assert results[index]['key'] == output['key']
assert results[index]['value'] == output['value']


if __name__ == '__main__': # pragma: no cover
pytest.main([__file__])

0 comments on commit 4114df7

Please sign in to comment.