mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
embedded bots: Add tests for verification of embedded bot services.
Add test to check if the embedded bot service being used is in the registry or not. Add test to check if the bot being added to the registry has a valid bot corresponding to it. Move 'get_bot_handler' to 'zerver/lib/bot_lib.py' as it is an independent function, not related to the 'EmbeddedBotWorker' class that it was previously a part of.
This commit is contained in:
committed by
Tim Abbott
parent
c13d466f68
commit
6f60c65a65
@@ -7,8 +7,10 @@ import signal
|
||||
import sys
|
||||
import time
|
||||
import re
|
||||
import importlib
|
||||
from zerver.lib.actions import internal_send_message
|
||||
from zerver.models import UserProfile
|
||||
from zerver.lib.integrations import EMBEDDED_BOTS
|
||||
|
||||
from six.moves import configparser
|
||||
|
||||
@@ -21,6 +23,16 @@ our_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
from zulip_bots.lib import RateLimit
|
||||
|
||||
def get_bot_handler(service_name):
|
||||
# type: (str) -> Any
|
||||
|
||||
# Assert that this service is present in EMBEDDED_BOTS.
|
||||
assert any(service_name == embedded_bot_service.name for embedded_bot_service in EMBEDDED_BOTS)
|
||||
|
||||
bot_module_name = 'zulip_bots.bots.%s.%s' % (service_name, service_name)
|
||||
bot_module = importlib.import_module(bot_module_name) # type: Any
|
||||
return bot_module.handler_class()
|
||||
|
||||
class EmbeddedBotHandler(object):
|
||||
def __init__(self, user_profile):
|
||||
# type: (UserProfile) -> None
|
||||
|
||||
Reference in New Issue
Block a user