Download tests/test_web_extractor.py from isold/MeloonTop: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/spaces/isold/MeloonTop/resolve/main/tests/test_web_extractor.py
- Command line
-
hf download hf://spaces/isold/MeloonTop/tests/test_web_extractor.py
-
curl -L -o test_web_extractor.py https://huggingface.co/spaces/isold/MeloonTop/resolve/main/tests/test_web_extractor.py
861 Bytes
| import pytest | |
| from fastapi.testclient import TestClient | |
| from app.main import app | |
| client = TestClient(app) | |
| def test_extract_metadata_success(): | |
| # Attempting to extract from a highly stable site like GitHub | |
| url = "https://github.com" | |
| response = client.get(f"/api/tools/extract-metadata?url={url}") | |
| assert response.status_code == 200 | |
| data = response.json() | |
| assert "title" in data | |
| assert "description" in data | |
| assert data["url"] == url | |
| # GitHub usually has 'GitHub' in the title | |
| assert "GitHub" in data["title"] | |
| def test_extract_metadata_invalid_url(): | |
| url = "https://this-is-definitely-not-a-real-website-12345.com" | |
| response = client.get(f"/api/tools/extract-metadata?url={url}") | |
| # It should return a 400 since it fails to extract | |
| assert response.status_code == 400 | |
| assert "detail" in response.json() | |