MCPcopy Create free account
hub / github.com/alibaba/zvec / test_embed_http_error

Method test_embed_http_error

python/tests/test_embedding.py:393–406  ·  view source on GitHub ↗

Test embedding with HTTP error.

(self, mock_require_module)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 2

embedMethod · 0.95
QwenSparseEmbeddingClass · 0.90

Tested by

no test coverage detected