Kaito117's picture
add tests, mod files to pass test
cc564ae
import json
from pathlib import Path
import pytest
import respx
from httpx import Response
from fastapi.testclient import TestClient
from app.main import app
@pytest.fixture(autouse=True)
def mock_http(respx_mock: respx.MockRouter):
# 1) Mock SerpAPI (Google) search
gh_search = json.loads(Path("test/data/github_search.json").read_text())
respx_mock.get("https://serpapi.com/search.json").mock(
return_value=Response(200, json=gh_search)
)
# 2) Mock GitHub profile HTML fetch
gh_html = Path("test/data/github_profile.html").read_text()
respx_mock.get(respx.MockRouter._compile(r"https://github\.com/.*")).mock(
return_value=Response(200, text=gh_html)
)
# 3) Mock RapidAPI LinkedIn profile fetch
ln_json = json.loads(Path("test/data/mock_linkedin.json").read_text())
respx_mock.get(respx.MockRouter._compile(r"https://fresh-linkedin-profile-data\.p\.rapidapi\.com/.*")).mock(
return_value=Response(200, json=ln_json)
)
yield
@pytest.fixture
def client() -> TestClient:
return TestClient(app)