From d6a4c02ba598e92a4b672c1313daf4883e5f2544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Tue, 28 Nov 2017 20:34:25 +0100 Subject: [PATCH] Rename bot storage endpoint from state to storage. --- zulip/zulip/__init__.py | 14 +++++++------- zulip_bots/zulip_bots/lib.py | 4 ++-- zulip_bots/zulip_bots/test_lib.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/zulip/zulip/__init__.py b/zulip/zulip/__init__.py index 3daa91e..c5456d7 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -878,12 +878,12 @@ class Client(object): ''' Example usage: - >>> client.update_storage({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) + >>> client.update_storage({'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) >>> client.get_storage({'keys': ["entry 1", "entry 3"]}) - {'result': 'success', 'state': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} + {'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} ''' return self.call_endpoint( - url='user_state', + url='bot_storage', method='PUT', request=request, ) @@ -893,14 +893,14 @@ class Client(object): ''' Example usage: - >>> client.update_storage({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) + >>> client.update_storage({'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) >>> client.get_storage() - {'result': 'success', 'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}, 'msg': ''} + {'result': 'success', 'storage': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}, 'msg': ''} >>> client.get_storage(keys=('entry 1', 'entry 3')) - {'result': 'success', 'state': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} + {'result': 'success', 'storage': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} ''' return self.call_endpoint( - url='user_state', + url='bot_storage', method='GET', request=request, ) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index 27afe5e..8cc7591 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -66,14 +66,14 @@ class StateHandler(object): self.demarshal = lambda obj: json.loads(obj) response = self._client.get_storage() if response['result'] == 'success': - self.state_ = response['state'] + self.state_ = response['storage'] else: raise StateHandlerError("Error initializing state: {}".format(str(response))) def put(self, key, value): # type: (Text, Text) -> None self.state_[key] = self.marshal(value) - response = self._client.update_storage({'state': {key: self.state_[key]}}) + response = self._client.update_storage({'storage': {key: self.state_[key]}}) if response['result'] != 'success': raise StateHandlerError("Error updating state: {}".format(str(response))) diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index 9ce75c0..2cd2c8a 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/zulip_bots/zulip_bots/test_lib.py @@ -46,7 +46,7 @@ class BotTestCaseBase(TestCase): self.MockClass = self.patcher.start() self.mock_bot_handler = self.MockClass(None, None, None, None) self.mock_client = MagicMock() - self.mock_client.get_storage.return_value = {'result': 'success', 'state': {}} + self.mock_client.get_storage.return_value = {'result': 'success', 'storage': {}} self.mock_client.update_storage.return_value = {'result': 'success'} self.mock_bot_handler.storage = StateHandler(self.mock_client) self.mock_bot_handler.send_message.return_value = {'id': 42}