import json import pytest import httpx import respx from gitea_mcp import list_notifications, mark_all_notifications_read BASE = "https://gitea.test/api/v1" @respx.mock def test_list_notifications_defaults(): route = respx.get(f"{BASE}/notifications").mock( return_value=httpx.Response(200, json=[{"id": 1, "unread": True}]) ) result = list_notifications() assert route.called params = dict(route.calls[0].request.url.params) assert params["limit"] == "20" assert params["all"] == "false" @respx.mock def test_list_notifications_include_read(): route = respx.get(f"{BASE}/notifications").mock( return_value=httpx.Response(200, json=[]) ) list_notifications(include_read=True) params = dict(route.calls[0].request.url.params) assert params["all"] == "true" @respx.mock def test_list_notifications_error(): respx.get(f"{BASE}/notifications").mock( return_value=httpx.Response(401, json={"message": "unauthorized"}) ) with pytest.raises(RuntimeError, match="401"): list_notifications() @respx.mock def test_mark_all_notifications_read(): route = respx.put(f"{BASE}/notifications").mock( return_value=httpx.Response(205) ) result = mark_all_notifications_read() assert route.called