Skip to content

Commit afc87fe

Browse files
committed
tests: json_db: add more asserts for clarity
1 parent 1119cb9 commit afc87fe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/test_jsondb.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,20 @@ async def test_jsonpatch_replace_after_remove(self):
9696
patches = [{"op": "add", "path": "/a/b", "value": "42"}]
9797
jpatch = jsonpatch.JsonPatch(patches)
9898
data = jpatch.apply(data)
99+
self.assertEqual(data, {'a': {"b": "42"}})
99100
# remove
100101
patches = [{"op": "remove", "path": "/a/b"}]
101102
jpatch = jsonpatch.JsonPatch(patches)
102103
data = jpatch.apply(data)
104+
self.assertEqual(data, {'a': {}})
103105
# replace
104106
patches = [{"op": "replace", "path": "/a/b", "value": "43"}]
105107
jpatch = jsonpatch.JsonPatch(patches)
106108
with self.assertRaises(JsonPatchException):
107109
data = jpatch.apply(data)
108110

109111
async def test_jsondb_replace_after_remove(self):
110-
data = { 'a': {'b': {'c': 0}}}
112+
data = { 'a': {'b': {'c': 0}}, 'd': 3}
111113
db = JsonDB(repr(data))
112114
a = db.get_dict('a')
113115
# remove
@@ -119,9 +121,10 @@ async def test_jsondb_replace_after_remove(self):
119121
patches = json.loads('[' + ','.join(db.pending_changes) + ']')
120122
jpatch = jsonpatch.JsonPatch(patches)
121123
data = jpatch.apply(data)
124+
self.assertEqual(data, {'a': {}, 'd': 3})
122125

123126
async def test_jsondb_replace_after_remove_nested(self):
124-
data = { 'a': {'b':{'c':0}}}
127+
data = { 'a': {'b': {'c': 0}}, 'd': 3}
125128
db = JsonDB(repr(data))
126129
# remove
127130
a = db.data.pop('a')
@@ -133,3 +136,4 @@ async def test_jsondb_replace_after_remove_nested(self):
133136
patches = json.loads('[' + ','.join(db.pending_changes) + ']')
134137
jpatch = jsonpatch.JsonPatch(patches)
135138
data = jpatch.apply(data)
139+
self.assertEqual(data, {'d': 3})

0 commit comments

Comments
 (0)