Download tests/test_function_validator.py from abcd118q/Nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/abcd118q/Nexus/resolve/main/tests/test_function_validator.py
- Command line
-
hf download hf://spaces/abcd118q/Nexus/tests/test_function_validator.py
-
curl -L -o test_function_validator.py https://huggingface.co/spaces/abcd118q/Nexus/resolve/main/tests/test_function_validator.py
1.07 kB
| import pytest | |
| from app.services.function_validator import validate_tool, clean_tool | |
| class TestFunctionValidator: | |
| def test_validate_tool_valid(self): | |
| tool = { | |
| "name": "get_weather", | |
| "description": "Get weather", | |
| "parameters": {"type": "object", "properties": {"city": {"type": "string"}}} | |
| } | |
| assert validate_tool(tool) is True | |
| def test_validate_tool_empty_name(self): | |
| tool = {"name": "", "parameters": {}} | |
| assert validate_tool(tool) is False | |
| def test_validate_tool_long_name(self): | |
| tool = {"name": "a" * 65, "parameters": {}} | |
| assert validate_tool(tool) is False | |
| def test_validate_tool_invalid_chars(self): | |
| tool = {"name": "get weather!", "parameters": {}} | |
| assert validate_tool(tool) is False | |
| def test_clean_tool(self): | |
| tool = {"name": "test", "description": "desc", "parameters": {"type": "object"}} | |
| cleaned = clean_tool(tool) | |
| assert cleaned["type"] == "function" | |
| assert cleaned["function"]["name"] == "test" | |