wuttasync/tests/test_util.py
Lance Edgar 33ac0e008e fix: format all code with black
and from now on should not deviate from that...
2025-08-31 12:42:59 -05:00

31 lines
938 B
Python

# -*- coding: utf-8; -*-
from unittest import TestCase
from wuttasync import util as mod
class TestDataDiffs(TestCase):
def test_source_missing_field(self):
source = {"foo": "bar"}
target = {"baz": "xyz", "foo": "bar"}
self.assertRaises(KeyError, mod.data_diffs, source, target)
def test_target_missing_field(self):
source = {"foo": "bar", "baz": "xyz"}
target = {"baz": "xyz"}
self.assertRaises(
KeyError, mod.data_diffs, source, target, fields=["foo", "baz"]
)
def test_no_diffs(self):
source = {"foo": "bar", "baz": "xyz"}
target = {"baz": "xyz", "foo": "bar"}
self.assertFalse(mod.data_diffs(source, target))
def test_with_diffs(self):
source = {"foo": "bar", "baz": "xyz"}
target = {"baz": "xyz", "foo": "BAR"}
result = mod.data_diffs(source, target)
self.assertEqual(result, ["foo"])