from fastapi.testclient import TestClient
from app.main import app
from unittest.mock import patch
client = TestClient(app)
@patch("app.routes.projects.fetch_repos")
def test_projects_page_shows_repos(mock_fetch):
mock_fetch.return_value = [
{"name": "Project1", "description": "Desc 1"},
{"name": "Project2", "description": "Desc 2"}
]
response = client.get("/projects")
assert response.status_code == 200
assert "Project1" in response.text
assert "Project2" in response.text
@patch("app.routes.projects.fetch_repos")
def test_projects_shows_message_when_empty(mock_fetch):
mock_fetch.return_value = []
response = client.get("/projects")
assert response.status_code == 200
assert "indisponibles" in response.text.lower()