Skip to content

Commit

Permalink
Merge pull request #7 from fga-eps-mds/fix-uncovered-tests
Browse files Browse the repository at this point in the history
Adiciona teste para tratamento de exceção em get_schedule_day
  • Loading branch information
DaviMarinho authored Dec 10, 2023
2 parents 319c746 + 95b7903 commit 0f04609
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/test_schedule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from fastapi.testclient import TestClient
from unittest.mock import patch

from src.main import app
from src.constants import errorMessages
Expand All @@ -26,4 +27,14 @@ def test_schedule_get_schedule_specific_day(self):
response = client.get("/api/schedule/", params=params)
data = response.json()
assert response.status_code == 200
assert len(data) > 0
assert len(data) > 0

def test_schedule_get_schedule_day_exception_handling(self):
with patch("src.controller.scheduleController.requests.get") as mock_get:
mock_get.side_effect = Exception("Test exception")

response = client.get("/api/schedule/")
data = response.json()

assert response.status_code == 400
assert data['error'] == errorMessages.ERROR_RETRIEVING_SCHEDULE

0 comments on commit 0f04609

Please sign in to comment.