zulip_bots: Rename state_handler to storage.

This commit is contained in:
derAnfaenger 2017-10-23 12:24:41 +02:00
parent eb6982e670
commit e331426c64
7 changed files with 21 additions and 21 deletions

View file

@ -12,7 +12,7 @@ class IncrementorHandler(object):
'''
def handle_message(self, message, bot_handler):
with bot_handler.state_handler.state({'number': 0, 'message_id': None}) as state:
with bot_handler.storage.state({'number': 0, 'message_id': None}) as state:
state['number'] += 1
if state['message_id'] is None:
result = bot_handler.send_reply(message, str(state['number']))

View file

@ -23,11 +23,11 @@ class TestIncrementorBot(BotTestCase):
'sender_email': 'foo_sender@zulip.com',
},
]
state_handler = StateHandler()
storage = StateHandler()
self.assert_bot_response(dict(messages[0], content=""), {'content': "1"},
'send_reply', state_handler)
'send_reply', storage)
# Last test commented out since we don't have update_message
# support in the test framework yet.
# self.assert_bot_response(dict(messages[0], content=""), {'message_id': 5, 'content': "2"},
# 'update_message', state_handler)
# 'update_message', storage)

View file

@ -281,7 +281,7 @@ class ticTacToeHandler(object):
command += val
original_sender = message['sender_email']
with bot_handler.state_handler.state({}) as mydict:
with bot_handler.storage.state({}) as mydict:
user_game = mydict.get(original_sender)
if (not user_game) and command == "new":
user_game = TicTacToeGame(copy.deepcopy(initial_board))

View file

@ -45,5 +45,5 @@ class TestVirtualFsBot(BotTestCase):
("cd /home", "foo_sender@zulip.com:\nCurrent path: /home/"),
]
state_handler = StateHandler()
self.check_expected_responses(expected, state_handler = state_handler)
storage = StateHandler()
self.check_expected_responses(expected, storage = storage)

View file

@ -18,7 +18,7 @@ class VirtualFsHandler(object):
if isinstance(recipient, list): # If not a stream, then hash on list of emails
recipient = " ".join([x['email'] for x in recipient])
with bot_handler.state_handler.state({}) as state:
with bot_handler.storage.state({}) as state:
if recipient not in state:
state[recipient] = fs_new()
fs = state[recipient]