From 95b790370bfdefbbf62e049c86545c0ae6a9a7a9 Mon Sep 17 00:00:00 2001 From: Diego Carlito Date: Sat, 9 Dec 2023 19:25:58 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20teste=20para=20tratamento=20de=20exc?= =?UTF-8?q?e=C3=A7=C3=A3o=20em=20get=5Fschedule=5Fday?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_schedule.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/test_schedule.py b/tests/test_schedule.py index e45753b..6cbfa46 100644 --- a/tests/test_schedule.py +++ b/tests/test_schedule.py @@ -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 @@ -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 \ No newline at end of file + 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 \ No newline at end of file