-
Notifications
You must be signed in to change notification settings - Fork 79
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
spandan_mondal
committed
Dec 2, 2024
1 parent
88e9da2
commit 3b8e43c
Showing
3 changed files
with
63 additions
and
4 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 |
---|---|---|
|
@@ -1216,10 +1216,38 @@ def test_trigger_mail_channel_schedule_event_enqueue(self): | |
except AppException as e: | ||
pytest.fail(f"Unexpected exception: {e}") | ||
|
||
@responses.activate | ||
def test_trigger_mail_channel_schedule_event_enqueue_exception(self): | ||
from kairon.events.definitions.mail_channel_schedule import MailChannelScheduleEvent | ||
from kairon.exceptions import AppException | ||
from unittest.mock import patch | ||
|
||
bot = "test_add_schedule_event" | ||
user = "test_user" | ||
url = f"http://localhost:5001/api/events/execute/{EventClass.email_channel_scheduler}?is_scheduled=False" | ||
responses.add( | ||
"POST", url, | ||
json={"message": "test msg", "success": False, "error_code": 400, "data": None} | ||
) | ||
event = MailChannelScheduleEvent(bot, user) | ||
with pytest.raises(AppException, match="Failed to trigger email_channel_scheduler event: test msg"): | ||
event.enqueue() | ||
|
||
@responses.activate | ||
def test_trigger_mail_channel_schedule_event_execute(self): | ||
from kairon.events.definitions.mail_channel_schedule import MailChannelScheduleEvent | ||
try: | ||
MailChannelScheduleEvent("", "").execute() | ||
except AppException as e: | ||
pytest.fail(f"Unexpected exception: {e}") | ||
pytest.fail(f"Unexpected exception: {e}") | ||
|
||
@responses.activate | ||
def test_trigger_mail_channel_schedule_event_execute_exception(self): | ||
from kairon.events.definitions.mail_channel_schedule import MailChannelScheduleEvent | ||
from kairon.exceptions import AppException | ||
from unittest.mock import patch | ||
|
||
with patch("kairon.shared.channels.mail.processor.MailProcessor.process_message_task", | ||
side_effect=Exception("Test")): | ||
with pytest.raises(AppException, match="Test"): | ||
MailChannelScheduleEvent("", "").execute(mails=["[email protected]"]) |