-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d09d2e
commit cc753e2
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import unittest | ||
from unittest.mock import patch | ||
from bot.error_handler import GoogleSheetError, TelegramBotError, DatabaseError | ||
|
||
class TestErrorHandling(unittest.TestCase): | ||
|
||
def test_google_sheet_error_raises_correctly(self): | ||
# Define the message and extra_info | ||
message = "Test failure in Google Sheets" | ||
extra_info = "Invalid Range" | ||
|
||
# Check if the exception is raised with the correct message | ||
with self.assertRaises(GoogleSheetError) as context: | ||
raise GoogleSheetError(message, extra_info) | ||
|
||
# Verify that the message in the exception is as expected | ||
self.assertEqual(str(context.exception), f"GoogleSheetError: {message}") | ||
|
||
def test_telegram_bot_error_raises_correctly(self): | ||
message = "Failed to send message" | ||
extra_info = "User not found" | ||
|
||
with self.assertRaises(TelegramBotError) as context: | ||
raise TelegramBotError(message, extra_info) | ||
|
||
self.assertEqual(str(context.exception), f"TelegramBotError: {message}") | ||
|
||
def test_database_error_raises_correctly(self): | ||
message = "Database connection failed" | ||
extra_info = "Timeout occurred" | ||
|
||
with self.assertRaises(DatabaseError) as context: | ||
raise DatabaseError(message, extra_info) | ||
|
||
self.assertEqual(str(context.exception), f"DatabaseError: {message}") |