Skip to content

Commit 1034a84

Browse files
committed
test(tests/test_models.py): add unit tests for EditResult's to_dict method to ensure correct serialization of result objects
1 parent fb87900 commit 1034a84

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_models.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,31 @@ def test_edit_text_file_contents_request():
158158
# Test validation error - missing required field
159159
with pytest.raises(ValidationError):
160160
EditTextFileContentsRequest()
161+
162+
163+
def test_edit_result_to_dict():
164+
"""Test EditResult's to_dict method."""
165+
# Test successful result
166+
result = EditResult(result="ok", hash="newhash123")
167+
result_dict = result.to_dict()
168+
assert result_dict == {
169+
"result": "ok",
170+
"hash": "newhash123",
171+
"reason": None,
172+
"content": None,
173+
}
174+
175+
# Test error result
176+
result = EditResult(
177+
result="error",
178+
reason="hash mismatch",
179+
hash="currenthash123",
180+
content="current content",
181+
)
182+
result_dict = result.to_dict()
183+
assert result_dict == {
184+
"result": "error",
185+
"reason": "hash mismatch",
186+
"hash": "currenthash123",
187+
"content": "current content",
188+
}

0 commit comments

Comments
 (0)