1
0
personal-data/test/test_deduplicate.py

30 lines
841 B
Python

from frozendict import frozendict
from personal_data.data import DeduplicateMode
from personal_data.main import deduplicate_dicts
LIST = [
frozendict({'a': 1, 'b': 2, 't': 300}),
frozendict({'a': 1, 'b': 2, 't': 301}),
frozendict({'a': 1, 'b': 2, 't': 302}),
frozendict({'a': 1, 'b': 2, 't': 303}),
]
def test_no_deduplicate():
ls, fields = deduplicate_dicts(LIST, DeduplicateMode.NONE, [])
assert fields == ['a', 'b', 't']
assert ls == LIST
def test_only_latest_no_fields():
ls, fields = deduplicate_dicts(LIST, DeduplicateMode.ONLY_LATEST, [])
assert fields == ['a', 'b', 't']
assert ls == LIST
def test_only_latest():
ls, fields = deduplicate_dicts(LIST, DeduplicateMode.ONLY_LATEST, ['t'])
assert fields == ['a', 'b', 't']
assert ls == [frozendict({'a': 1, 'b': 2, 't': 300})]