Skip to content

Commit

Permalink
add changelog and test
Browse files Browse the repository at this point in the history
  • Loading branch information
souvikg10 committed Jun 29, 2023
1 parent 01bdd15 commit 12e8ab6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog/1219.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The logger for rasa_sdk plugin will not throw traceback when no plugins are found since plugins are optional. It will be only available in debug mode, however the action server will continue to run.
20 changes: 16 additions & 4 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import warnings

import logging
import pytest
from pytest import MonkeyPatch
from pluggy import PluginManager
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch

from rasa_sdk import endpoint
from rasa_sdk.plugin import plugin_manager

from rasa_sdk.plugin import plugin_manager, _discover_plugins
logger = logging.getLogger(__name__)

def test_plugin_manager() -> None:
manager = plugin_manager()
Expand Down Expand Up @@ -38,3 +39,14 @@ def test_plugin_attach_sanic_app_extension(
warnings.simplefilter("error")
endpoint.run("actions")
manager.hook.attach_sanic_app_extensions.assert_called_once_with(app=app_mock)

def test_plugins_not_found(monkeypatch):
# Mock the import statement to raise ModuleNotFoundError
monkeypatch.setitem(__builtins__, 'import', MagicMock(side_effect=ModuleNotFoundError))

# Call the method under test
try:
import rasa_sdk_plugins
except ModuleNotFoundError as e:
# Assert the expected exception message or other details if needed
assert str(e) == "No module named 'rasa_sdk_plugins'"

0 comments on commit 12e8ab6

Please sign in to comment.