From 63efed5c739808c769690f857dea4251c344331b Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Mon, 22 May 2017 08:35:07 +0530 Subject: [PATCH] Refactor: Make StateHandler() function independent. This refactor makes the nested class 'StateHandler' in the file /contrib_bots/bot_lib.py independent class. It previously was nested in 'run_message_handler_for_bot' function. This is done to write a cleaner test file for contrib_bots using mock library. --- contrib_bots/bot_lib.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/contrib_bots/bot_lib.py b/contrib_bots/bot_lib.py index 6bbb55c..e1f7e89 100644 --- a/contrib_bots/bot_lib.py +++ b/contrib_bots/bot_lib.py @@ -71,6 +71,16 @@ class BotHandlerApi(object): content=response, )) +class StateHandler(object): + def __init__(self): + self.state = None + + def set_state(self, state): + self.state = state + + def get_state(self): + return self.state + def run_message_handler_for_bot(lib_module, quiet, config_file): # Make sure you set up your ~/.zuliprc client = Client(config_file=config_file) @@ -78,16 +88,6 @@ def run_message_handler_for_bot(lib_module, quiet, config_file): message_handler = lib_module.handler_class() - class StateHandler(object): - def __init__(self): - self.state = None - - def set_state(self, state): - self.state = state - - def get_state(self): - return self.state - state_handler = StateHandler() if not quiet: