From afc87fea9aa2b84961c0ae4556b9964a8e2cbb5f Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 1 Dec 2025 19:33:14 +0000 Subject: [PATCH] tests: json_db: add more asserts for clarity --- tests/test_jsondb.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_jsondb.py b/tests/test_jsondb.py index eeaf41079..f0cf30bb5 100644 --- a/tests/test_jsondb.py +++ b/tests/test_jsondb.py @@ -96,10 +96,12 @@ class TestJsonDB(ElectrumTestCase): patches = [{"op": "add", "path": "/a/b", "value": "42"}] jpatch = jsonpatch.JsonPatch(patches) data = jpatch.apply(data) + self.assertEqual(data, {'a': {"b": "42"}}) # remove patches = [{"op": "remove", "path": "/a/b"}] jpatch = jsonpatch.JsonPatch(patches) data = jpatch.apply(data) + self.assertEqual(data, {'a': {}}) # replace patches = [{"op": "replace", "path": "/a/b", "value": "43"}] jpatch = jsonpatch.JsonPatch(patches) @@ -107,7 +109,7 @@ class TestJsonDB(ElectrumTestCase): data = jpatch.apply(data) async def test_jsondb_replace_after_remove(self): - data = { 'a': {'b': {'c': 0}}} + data = { 'a': {'b': {'c': 0}}, 'd': 3} db = JsonDB(repr(data)) a = db.get_dict('a') # remove @@ -119,9 +121,10 @@ class TestJsonDB(ElectrumTestCase): patches = json.loads('[' + ','.join(db.pending_changes) + ']') jpatch = jsonpatch.JsonPatch(patches) data = jpatch.apply(data) + self.assertEqual(data, {'a': {}, 'd': 3}) async def test_jsondb_replace_after_remove_nested(self): - data = { 'a': {'b':{'c':0}}} + data = { 'a': {'b': {'c': 0}}, 'd': 3} db = JsonDB(repr(data)) # remove a = db.data.pop('a') @@ -133,3 +136,4 @@ class TestJsonDB(ElectrumTestCase): patches = json.loads('[' + ','.join(db.pending_changes) + ']') jpatch = jsonpatch.JsonPatch(patches) data = jpatch.apply(data) + self.assertEqual(data, {'d': 3})