Skip to content

Commit 7327cd7

Browse files
test: cover add()-to-list and upsert()-on-scalar-root routing errors
Add two missing cases to TestRoutingErrorBehaviour: - test_add_through_list_raises_routing_error: add() through a list node was untested; only the scalar-node case existed. - test_upsert_scalar_root_raises_routing_error: exercises the _create_at(parent_keys=(), ...) branch on a non-empty document and pins the '<root>' token in RoutingError messages.
1 parent 78118d0 commit 7327cd7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_errors.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,13 @@ def test_routing_error_is_catchable_as_patch_error(self):
8282
doc = Document("a: scalar\n")
8383
with pytest.raises(PatchError):
8484
doc.upsert("a", "b", value="foo")
85+
86+
def test_add_through_list_raises_routing_error(self):
87+
doc = Document("items:\n - a\n")
88+
with pytest.raises(RoutingError, match="non-mapping node at items"):
89+
doc.add("items", key="child", value="foo")
90+
91+
def test_upsert_scalar_root_raises_routing_error(self):
92+
doc = Document("just_a_scalar\n")
93+
with pytest.raises(RoutingError, match=r"non-mapping node at <root>"):
94+
doc.upsert("y", value="v")

0 commit comments

Comments
 (0)