Spaces:
Running
Running
Download tests/test_compatibility.py from Leon4gr45/needle: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/Leon4gr45/needle/resolve/main/tests/test_compatibility.py
- Command line
-
hf download hf://spaces/Leon4gr45/needle/tests/test_compatibility.py
-
curl -L -o test_compatibility.py https://huggingface.co/spaces/Leon4gr45/needle/resolve/main/tests/test_compatibility.py
1.26 kB
| import pytest | |
| from models import ChatCompletionRequest, Message | |
| def test_chat_completion_request_parsing(): | |
| req = ChatCompletionRequest( | |
| model="needle3", | |
| messages=[ | |
| Message(role="user", content="hello") | |
| ], | |
| tools=[{"name": "test", "description": "desc", "parameters": {"type": "object"}}] | |
| ) | |
| assert req.model == "needle3" | |
| assert len(req.messages) == 1 | |
| assert req.messages[0].content == "hello" | |
| assert len(req.tools) == 1 | |
| def test_mcp_input_schema_and_openai_strict_shapes(): | |
| from registry import normalize_tool | |
| schema={'type':'object','properties':{'path':{'type':'string'}},'required':['path']} | |
| mcp={'name':'read_file','description':'Read file','inputSchema':schema,'annotations':{'readOnlyHint':True}} | |
| openai={'type':'function','function':{'name':'read_file','description':'Read file','parameters':schema,'strict':True}} | |
| assert normalize_tool(mcp)==normalize_tool(openai) | |
| def test_conflicting_mcp_and_native_schemas_are_rejected(): | |
| import pytest | |
| from registry import normalize_tool | |
| with pytest.raises(ValueError,match='conflicting'): | |
| normalize_tool({'name':'read','description':'Read','parameters':{'type':'object'},'inputSchema':{'type':'string'}}) | |