bumblebee-status/tests/util/test_algorithm.py

51 lines
1.4 KiB
Python
Raw Normal View History

2020-06-20 14:53:44 +02:00
import pytest
from util.algorithm import *
2020-06-20 14:53:44 +02:00
@pytest.fixture
def someData():
return {"a": 100, "b": 200, "c": [1, 2, 3]}
2020-06-20 14:53:44 +02:00
@pytest.fixture
def differentData():
return {"x": 20, "y": "bla", "z": ["a", "b"]}
2020-06-20 14:53:44 +02:00
@pytest.fixture
def moreData():
return {"n": 100}
2020-06-20 14:53:44 +02:00
@pytest.fixture
def overlapData():
return {"a": 200, "c": [1, 2, 4]}
2020-06-20 14:53:44 +02:00
def test_merge_with_empty(someData):
assert merge(someData, {}) == someData
assert merge(someData, None) == None
2020-06-20 14:53:44 +02:00
def test_merge_no_overwrite(someData, differentData):
result = merge(someData, differentData)
for k in someData:
assert someData[k] == result[k]
for k in self.differentData:
assert differentData[k] == result[k]
def test_merge_multiple(someData, differentData, moreData):
result = merge(someData, differentData, moreData)
for k in someData:
assert someData[k] == result[k]
for k in differentData:
assert differentData[k] == result[k]
for k in moreData:
assert moreData[k] == result[k]
def merge_overlap(someData, overlapData):
result = merge(someData, overlapData)
for k in someData:
if not k in self.overlapData:
2020-06-20 14:53:44 +02:00
assert someData[k] == result[k]
for k in self.overlapData:
2020-06-20 14:53:44 +02:00
assert overlapData[k] == result[k]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4