| import pytest |
| from app.services.format_adapter import detect_input_format |
|
|
|
|
| class TestFormatAdapter: |
| @pytest.mark.asyncio |
| async def test_detect_openai_chat_format(self): |
| body = {"model": "gpt-4", "messages": [{"role": "user", "content": "hi"}]} |
| fmt = await detect_input_format(body) |
| assert fmt == "openai_chat" |
|
|
| @pytest.mark.asyncio |
| async def test_detect_anthropic_format(self): |
| body = {"model": "claude-3", "anthropic_version": "2023-06-01", "messages": [{"role": "user", "content": "hi"}]} |
| fmt = await detect_input_format(body) |
| assert fmt == "anthropic" |
|
|
| @pytest.mark.asyncio |
| async def test_detect_gemini_format(self): |
| body = {"contents": [{"parts": [{"text": "hi"}]}]} |
| fmt = await detect_input_format(body) |
| assert fmt == "gemini" |
|
|
| @pytest.mark.asyncio |
| async def test_detect_responses_format(self): |
| body = {"input": "hi", "model": "gpt-4o"} |
| fmt = await detect_input_format(body) |
| assert fmt == "openai_responses" |
|
|