Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adiciona teste para tratamento de exceção em get_schedule_day #7

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading