|
8 | 8 | EditPatch,
|
9 | 9 | EditResult,
|
10 | 10 | EditTextFileContentsRequest,
|
| 11 | + FileRange, |
| 12 | + FileRanges, |
11 | 13 | GetTextFileContentsRequest,
|
12 | 14 | GetTextFileContentsResponse,
|
13 | 15 | )
|
@@ -186,3 +188,43 @@ def test_edit_result_to_dict():
|
186 | 188 | "hash": "currenthash123",
|
187 | 189 | "content": "current content",
|
188 | 190 | }
|
| 191 | + |
| 192 | + |
| 193 | +def test_file_range(): |
| 194 | + """Test FileRange model.""" |
| 195 | + # Test with only required field |
| 196 | + range_ = FileRange(start=1) |
| 197 | + assert range_.start == 1 |
| 198 | + assert range_.end is None # Default value |
| 199 | + |
| 200 | + # Test with all fields |
| 201 | + range_ = FileRange(start=5, end=10) |
| 202 | + assert range_.start == 5 |
| 203 | + assert range_.end == 10 |
| 204 | + |
| 205 | + # Test validation error - missing required field |
| 206 | + with pytest.raises(ValidationError): |
| 207 | + FileRange() |
| 208 | + |
| 209 | + |
| 210 | +def test_file_ranges(): |
| 211 | + """Test FileRanges model.""" |
| 212 | + ranges = [ |
| 213 | + FileRange(start=1), |
| 214 | + FileRange(start=5, end=10), |
| 215 | + ] |
| 216 | + file_ranges = FileRanges(file_path="/path/to/file.txt", ranges=ranges) |
| 217 | + assert file_ranges.file_path == "/path/to/file.txt" |
| 218 | + assert len(file_ranges.ranges) == 2 |
| 219 | + assert file_ranges.ranges[0].start == 1 |
| 220 | + assert file_ranges.ranges[0].end is None |
| 221 | + assert file_ranges.ranges[1].start == 5 |
| 222 | + assert file_ranges.ranges[1].end == 10 |
| 223 | + |
| 224 | + # Test validation error - missing required fields |
| 225 | + with pytest.raises(ValidationError): |
| 226 | + FileRanges() |
| 227 | + |
| 228 | + # Test validation error - invalid ranges type |
| 229 | + with pytest.raises(ValidationError): |
| 230 | + FileRanges(file_path="/path/to/file.txt", ranges="invalid") |
0 commit comments