Skip to content

Commit 1640500

Browse files
NRL-1215 Add extra edge case
1 parent 3e40977 commit 1640500

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

layer/nrlf/core/tests/test_json_duplicate_checker.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ def test_same_level_duplicates(self):
2828
self.assertEqual(duplicates, ['b'])
2929
self.assertEqual(paths, ['root.a.b'])
3030

31+
def test_same_level_duplicates_objects(self):
32+
# This JSON has duplicates because there are two 'b' keys at the same level
33+
# The difference with above is that the 'b' keys are objects and every element in the object is the same
34+
json_content = '{"a": {"b": { "f": 4, "g": 5 }, "b": { "f": 4, "g": 5 } }, "c": {"d": 3}}'
35+
duplicates, paths = check_duplicate_keys(json_content)
36+
self.assertEqual(duplicates, ['b'])
37+
self.assertEqual(paths, ['root.a.b'])
38+
3139
def test_multiple_level_duplicates(self):
3240
# This JSON has duplicates at multiple levels
3341
json_content = '{"a": 1, "b": {"c": 2, "c": 3}, "a": 4}'

0 commit comments

Comments
 (0)