Download tests/test_explore.py from Aaryan17/MAC: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/Aaryan17/MAC/resolve/main/tests/test_explore.py
- Command line
-
hf download hf://spaces/Aaryan17/MAC/tests/test_explore.py
-
curl -L -o test_explore.py https://huggingface.co/spaces/Aaryan17/MAC/resolve/main/tests/test_explore.py
2.17 kB
| """Tests for /explore endpoints.""" | |
| import pytest | |
| async def test_root(client): | |
| resp = await client.get("/") | |
| assert resp.status_code == 200 | |
| # Root may return HTML (frontend) or JSON depending on mount order | |
| try: | |
| data = resp.json() | |
| assert "MAC" in data.get("name", "") | |
| except Exception: | |
| # Frontend HTML served — still valid | |
| assert "MAC" in resp.text or "html" in resp.text.lower() | |
| async def test_api_root(client): | |
| resp = await client.get("/api/v1") | |
| assert resp.status_code == 200 | |
| assert "auth" in resp.json()["endpoints"] | |
| async def test_explore_models(client): | |
| resp = await client.get("/api/v1/explore/models") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert "models" in data | |
| assert "total" in data | |
| async def test_explore_models_search(client): | |
| resp = await client.get("/api/v1/explore/models/search?tag=code") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert isinstance(data["models"], list) | |
| async def test_explore_endpoints_list(client): | |
| resp = await client.get("/api/v1/explore/endpoints") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert data["total"] > 0 | |
| assert any("/auth/login" in e["path"] for e in data["endpoints"]) | |
| async def test_explore_health(client): | |
| resp = await client.get("/api/v1/explore/health") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert data["status"] == "healthy" | |
| assert data["version"] == "1.0.0" | |
| async def test_explore_model_detail(client): | |
| resp = await client.get("/api/v1/explore/models/qwen2.5-coder:7b") | |
| assert resp.status_code == 200 | |
| data = resp.json() | |
| assert data["id"] == "qwen2.5-coder:7b" | |
| assert "code" in data["capabilities"] | |
| async def test_explore_model_not_found(client): | |
| resp = await client.get("/api/v1/explore/models/nonexistent-model") | |
| assert resp.status_code == 404 | |