def test_complex_nested_operations(editor: ArtifactEditorToolSpec):
    """Test complex operations on deeply nested structures."""
    complex_data = {
        "name": "John",
        "age": 30,
        "address": {"street": "123 Main St", "city": "Springfield", "zipcode": "12345"},
        "tags": ["python", "developer"],
    }

    editor.create_artifact(**complex_data)

    patch = JsonPatch(
        operations=[
            PatchOperation(op="replace", path="/address/street", value="456 Oak Ave"),
            PatchOperation(op="add", path="/tags/-", value="senior"),
            PatchOperation(op="remove", path="/tags/0"),  # Remove "python"
        ]
    )

    result = editor.apply_patch(patch)

    assert result["address"]["street"] == "456 Oak Ave"
    assert "senior" in result["tags"]
    assert "python" not in result["tags"]
    assert result["age"] == 30
Test complex operations on deeply nested structures.
llama-index-integrations/tools/llama-index-tools-artifact-editor/tests/test_artifact_editor.py