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()