Test embedding with HTTP error.
(self, mock_require_module)
| 391 | |
| 392 | @patch("zvec.extension.qwen_function.require_module") |
| 393 | def test_embed_http_error(self, mock_require_module): |
| 394 | """Test embedding with HTTP error.""" |
| 395 | mock_dashscope = MagicMock() |
| 396 | mock_response = MagicMock() |
| 397 | mock_response.status_code = HTTPStatus.BAD_REQUEST |
| 398 | mock_response.message = "Bad Request" |
| 399 | mock_dashscope.TextEmbedding.call.return_value = mock_response |
| 400 | mock_require_module.return_value = mock_dashscope |
| 401 | |
| 402 | embedding_func = QwenSparseEmbedding(dimension=1024, api_key="test_key") |
| 403 | embedding_func.embed.cache_clear() |
| 404 | |
| 405 | with pytest.raises(ValueError, match="DashScope API error"): |
| 406 | embedding_func.embed("test text") |
| 407 | |
| 408 | @patch("zvec.extension.qwen_function.require_module") |
| 409 | def test_embed_invalid_response_no_embeddings(self, mock_require_module): |
nothing calls this directly
no test coverage detected