bots: Make StateHandler store state on Zulip server.
This makes the StateHandler functional. To reduce the number of server roundtrips when fetching/updating the state, the entire state is fetched ocne at bot initialization and cached. All changes are stored in the cache and only saved externally after handle_message() has been executed. Fixes #141.
This commit is contained in:
parent
979bbb1c14
commit
2736223073
3 changed files with 32 additions and 8 deletions
|
@ -45,7 +45,9 @@ class BotTestCaseBase(TestCase):
|
|||
self.patcher = patch('zulip_bots.lib.ExternalBotHandler', autospec=True)
|
||||
self.MockClass = self.patcher.start()
|
||||
self.mock_bot_handler = self.MockClass(None, None)
|
||||
self.mock_bot_handler.storage = StateHandler()
|
||||
self.mock_client = MagicMock()
|
||||
self.mock_client.get_state.return_value = {'result': 'success', 'state': {}}
|
||||
self.mock_bot_handler.storage = StateHandler(self.mock_client)
|
||||
self.mock_bot_handler.send_message.return_value = {'id': 42}
|
||||
self.mock_bot_handler.send_reply.return_value = {'id': 42}
|
||||
self.message_handler = self.get_bot_message_handler()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue