============================= test session starts =============================
platform win32 -- Python 3.11.9, pytest-9.0.1, pluggy-1.6.0
rootdir: C:\Users\rahul\.gemini\antigravity\playground\vector-meteoroid\qwed_new
configfile: pytest.ini (WARNING: ignoring pytest config in pyproject.toml!)
plugins: anyio-4.11.0, locust-2.42.6, asyncio-1.3.0, cov-7.0.0, timeout-2.4.0, xdist-3.8.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 10 items

tests\test_provider_coverage.py FF....F.F.                               [100%]

================================== FAILURES ===================================
_______________ TestOpenAIDirectHappyPaths.test_translate_happy _______________

self = <tests.test_provider_coverage.TestOpenAIDirectHappyPaths object at 0x0000023A67699E50>
mock_openai_cls = <MagicMock name='OpenAI' id='2449866387664'>

    @patch("qwed_new.providers.openai_direct.OpenAI")
    def test_translate_happy(self, mock_openai_cls):
        mock_client = MagicMock()
        mock_openai_cls.return_value = mock_client
        mock_client.chat.completions.create.return_value = _create_mock_tool_response('{"expression": "2+2", "result": "4"}')
        provider = OpenAIDirectProvider(api_key="sk-test")
>       result = provider.translate("my query")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests\test_provider_coverage.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <qwed_new.providers.openai_direct.OpenAIDirectProvider object at 0x0000023A66688690>
user_query = 'my query'

        def translate(self, user_query: str) -> MathVerificationTask:
            system = """You are a mathematical expression translator.
    Convert natural language math questions into formal mathematical expressions.
    Rules:
    1. Use Python math syntax
    2. Do NOT use variable names (except constants)
    3. Convert percentages to decimals
    4. Always calculate the numerical answer
    You MUST use the submit_math_expression tool."""
    
            try:
                result = self._call_with_tool(system, user_query, self.math_tool, "submit_math_expression")
                return MathVerificationTask(**result)
            except Exception as e:
                logger.debug("OpenAI translation error: %s", type(e).__name__)
>               raise ValueError("OpenAI translation failed.") from None
E               ValueError: OpenAI translation failed.

src\qwed_new\providers\openai_direct.py:105: ValueError
__________ TestOpenAIDirectHappyPaths.test_translate_empty_response ___________

self = <tests.test_provider_coverage.TestOpenAIDirectHappyPaths object at 0x0000023A6769AAD0>
mock_openai_cls = <MagicMock name='OpenAI' id='2449866333200'>

    @patch("qwed_new.providers.openai_direct.OpenAI")
    def test_translate_empty_response(self, mock_openai_cls):
        mock_client = MagicMock()
        mock_openai_cls.return_value = mock_client
        mock_client.chat.completions.create.return_value = _create_mock_response("")
        provider = OpenAIDirectProvider(api_key="sk-test")
        with pytest.raises(ValueError, match="OpenAI returned an empty or invalid response"):
>           provider.translate_stats("my stats", ["col1"])

tests\test_provider_coverage.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <qwed_new.providers.openai_direct.OpenAIDirectProvider object at 0x0000023A67699050>
query = 'my stats', columns = ['col1']

        def translate_stats(self, query: str, columns: List[str]) -> str:
            system = """You are a Python Data Science Expert.
    Write Python code using Pandas to verify a claim about a dataset.
    The dataset is loaded into `df`. Assign final result to `result`.
    Output ONLY Python code. No markdown."""
    
            try:
                return self._call_text(system, f"Columns: {columns}\nQuery: {query}")
            except Exception as e:
                logger.debug("OpenAI stats translation error: %s", type(e).__name__)
>               raise ValueError("OpenAI stats translation failed.") from None
E               ValueError: OpenAI stats translation failed.

src\qwed_new\providers\openai_direct.py:191: ValueError

During handling of the above exception, another exception occurred:

self = <tests.test_provider_coverage.TestOpenAIDirectHappyPaths object at 0x0000023A6769AAD0>
mock_openai_cls = <MagicMock name='OpenAI' id='2449866333200'>

    @patch("qwed_new.providers.openai_direct.OpenAI")
    def test_translate_empty_response(self, mock_openai_cls):
        mock_client = MagicMock()
        mock_openai_cls.return_value = mock_client
        mock_client.chat.completions.create.return_value = _create_mock_response("")
        provider = OpenAIDirectProvider(api_key="sk-test")
>       with pytest.raises(ValueError, match="OpenAI returned an empty or invalid response"):
E       AssertionError: Regex pattern did not match.
E         Expected regex: 'OpenAI returned an empty or invalid response'
E         Actual message: 'OpenAI stats translation failed.'

tests\test_provider_coverage.py:51: AssertionError
_______________ TestOpenAICompatHappyPaths.test_translate_happy _______________

self = <tests.test_provider_coverage.TestOpenAICompatHappyPaths object at 0x0000023A676A4B10>
mock_openai_cls = <MagicMock name='OpenAI' id='2449867607504'>

    @patch("qwed_new.providers.openai_compat.OpenAI")
    def test_translate_happy(self, mock_openai_cls):
        mock_client = MagicMock()
        mock_openai_cls.return_value = mock_client
        mock_client.chat.completions.create.return_value = _create_mock_response('```json\n{"expression": "2+2", "result": "4"}\n```')
        provider = OpenAICompatProvider(base_url="http://val", api_key="sk")
>       result = provider.translate("query")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests\test_provider_coverage.py:99: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <qwed_new.providers.openai_compat.OpenAICompatProvider object at 0x0000023A677F6A50>
user_query = 'query'

        def translate(self, user_query: str) -> MathVerificationTask:
            system = """You are a mathematical expression translator.
    Convert natural language math to formal expressions.
    Respond with JSON: {"expression": "...", "claimed_answer": ..., "reasoning": "...", "confidence": 0.95}"""
    
            try:
                result = self._call_json(system, user_query)
                return MathVerificationTask(**result)
            except Exception as e:
                logger.debug("OpenAI-Compatible translation error: %s", type(e).__name__)
>               raise ValueError("OpenAI-Compatible translation failed.") from None
E               ValueError: OpenAI-Compatible translation failed.

src\qwed_new\providers\openai_compat.py:111: ValueError
__________________ TestOllamaHappyPaths.test_translate_happy __________________

self = <tests.test_provider_coverage.TestOllamaHappyPaths object at 0x0000023A676A5310>
mock_openai_cls = <MagicMock name='OpenAI' id='2449867722192'>

    @patch("qwed_new.providers.ollama_provider.OpenAI")
    def test_translate_happy(self, mock_openai_cls):
        mock_client = MagicMock()
        mock_openai_cls.return_value = mock_client
        mock_client.chat.completions.create.return_value = _create_mock_response('```json\n{"expression": "2+2", "result": "4"}\n```')
        provider = OllamaProvider()
>       result = provider.translate("query")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests\test_provider_coverage.py:115: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <qwed_new.providers.ollama_provider.OllamaProvider object at 0x0000023A6780DFD0>
user_query = 'query'

        def translate(self, user_query: str) -> MathVerificationTask:
            system = """You are a mathematical expression translator.
    Convert natural language math to formal expressions.
    Respond with JSON: {"expression": "...", "claimed_answer": ..., "reasoning": "...", "confidence": 0.95}"""
    
            try:
                result = self._call_json(system, user_query)
                return MathVerificationTask(**result)
            except Exception as e:
                logger.debug("Ollama translation error: %s", type(e).__name__)
>               raise ValueError("Ollama translation failed.") from None
E               ValueError: Ollama translation failed.

src\qwed_new\providers\ollama_provider.py:81: ValueError
=========================== short test summary info ===========================
FAILED tests/test_provider_coverage.py::TestOpenAIDirectHappyPaths::test_translate_happy
FAILED tests/test_provider_coverage.py::TestOpenAIDirectHappyPaths::test_translate_empty_response
FAILED tests/test_provider_coverage.py::TestOpenAICompatHappyPaths::test_translate_happy
FAILED tests/test_provider_coverage.py::TestOllamaHappyPaths::test_translate_happy
========================= 4 failed, 6 passed in 1.15s =========================
