chore: update development dependencies and improve test coverage
Some checks failed
CI / lint-and-test (push) Failing after 11s
Some checks failed
CI / lint-and-test (push) Failing after 11s
- Upgraded `pytest-asyncio` to version 1.0 to ensure compatibility with the latest features and improvements. - Increased the coverage threshold in pytest configuration to 80%, enhancing the quality assurance process. - Added a new `conftest.py` file to manage shared fixtures and improve test organization. - Introduced multiple new test files to cover various components, ensuring comprehensive test coverage across the application. - Updated the `.coverage` file to reflect the latest coverage metrics.
This commit is contained in:
@@ -311,3 +311,47 @@ def test_calendar_ical_200_returns_only_that_users_duties(
|
||||
assert len(duties_arg) == 1
|
||||
assert duties_arg[0][0].user_id == 1
|
||||
assert duties_arg[0][1] == "User A"
|
||||
|
||||
|
||||
# --- /api/calendar-events ---
|
||||
|
||||
|
||||
@patch("duty_teller.api.app.config.EXTERNAL_CALENDAR_ICS_URL", "")
|
||||
@patch("duty_teller.api.app.config.MINI_APP_SKIP_AUTH", True)
|
||||
def test_calendar_events_empty_url_returns_empty_list(client):
|
||||
"""When EXTERNAL_CALENDAR_ICS_URL is empty, GET /api/calendar-events returns [] without fetch."""
|
||||
with patch("duty_teller.api.app.get_calendar_events") as mock_get:
|
||||
r = client.get(
|
||||
"/api/calendar-events",
|
||||
params={"from": "2025-01-01", "to": "2025-01-31"},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
assert r.json() == []
|
||||
mock_get.assert_not_called()
|
||||
|
||||
|
||||
@patch("duty_teller.api.app.config.EXTERNAL_CALENDAR_ICS_URL", "https://example.com/cal.ics")
|
||||
@patch("duty_teller.api.app.config.MINI_APP_SKIP_AUTH", True)
|
||||
def test_calendar_events_200_returns_list_with_date_summary(client):
|
||||
"""GET /api/calendar-events with auth and URL set returns list of {date, summary}."""
|
||||
with patch("duty_teller.api.app.get_calendar_events") as mock_get:
|
||||
mock_get.return_value = [
|
||||
{"date": "2025-01-15", "summary": "Team meeting"},
|
||||
{"date": "2025-01-20", "summary": "Review"},
|
||||
]
|
||||
r = client.get(
|
||||
"/api/calendar-events",
|
||||
params={"from": "2025-01-01", "to": "2025-01-31"},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
data = r.json()
|
||||
assert len(data) == 2
|
||||
assert data[0]["date"] == "2025-01-15"
|
||||
assert data[0]["summary"] == "Team meeting"
|
||||
assert data[1]["date"] == "2025-01-20"
|
||||
assert data[1]["summary"] == "Review"
|
||||
mock_get.assert_called_once_with(
|
||||
"https://example.com/cal.ics",
|
||||
from_date="2025-01-01",
|
||||
to_date="2025-01-31",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user