Test content handlers.
(self)
| 188 | self.assert_test(stat.st_size > 0, result) |
| 189 | |
| 190 | async def test_handlers(self): |
| 191 | """Test content handlers.""" |
| 192 | print("\n=== Testing Content Handlers ===") |
| 193 | |
| 194 | # Test TextHandler |
| 195 | text_handler = TextHandler() |
| 196 | test_data = b"Hello, Handler World!" |
| 197 | request = FileReadRequest(path=Path("test.txt")) |
| 198 | result = await text_handler.decode(test_data, request) |
| 199 | self.assert_test(result.content_text == "Hello, Handler World!", result) |
| 200 | |
| 201 | # Test JsonHandler |
| 202 | json_handler = JsonHandler() |
| 203 | json_data = b'{"name": "test", "value": 123}' |
| 204 | request = FileReadRequest(path=Path("test.json")) |
| 205 | result = await json_handler.decode(json_data, request) |
| 206 | self.assert_test("JSON Object with keys" in result.preview, result) |
| 207 | |
| 208 | # Test HandlerRegistry |
| 209 | registry = HandlerRegistry() |
| 210 | registry.register(text_handler) |
| 211 | registry.register(json_handler) |
| 212 | |
| 213 | handler = registry.find_for_extension('.txt') |
| 214 | self.assert_test(handler is not None, result) |
| 215 | |
| 216 | # Test supported extensions |
| 217 | extensions = registry.get_supported_extensions() |
| 218 | self.assert_test('.txt' in extensions and '.json' in extensions, result) |
| 219 | |
| 220 | async def test_error_handling(self): |
| 221 | """Test error handling.""" |
no test coverage detected