From f41030b515e45e04ea1b9f3d7241cf4ac84abfa8 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Mon, 13 Nov 2017 09:57:41 +0100 Subject: [PATCH] API: rename get_state & update_state to get_storage & update_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 b5c5617..fc9cbf3 100644 --- a/zulip/zulip/__init__.py +++ b/zulip/zulip/__init__.py @@ -859,13 +859,13 @@ class Client(object): request=request, ) - def update_state(self, request): + def update_storage(self, request): # type: (Dict[str, Any]) -> Dict[str, Any] ''' Example usage: - >>> client.update_state({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) - >>> client.get_state({'keys': ["entry 1", "entry 3"]}) + >>> client.update_storage({'state': {"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': ''} ''' return self.call_endpoint( @@ -874,15 +874,15 @@ class Client(object): request=request, ) - def get_state(self, request=None): + def get_storage(self, request=None): # type: (Optional[Dict[str, Any]]) -> Dict[str, Any] ''' Example usage: - >>> client.update_state({'state': {"entry 1": "value 1", "entry 2": "value 2", "entry 3": "value 3"}}) - >>> client.get_state() + >>> client.update_storage({'state': {"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': ''} - >>> client.get_state(keys=('entry 1', 'entry 3')) + >>> client.get_storage(keys=('entry 1', 'entry 3')) {'result': 'success', 'state': {'entry 1': 'value 1', 'entry 3': 'value 3'}, 'msg': ''} ''' return self.call_endpoint( diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index d5d802a..b24d7cb 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -61,7 +61,7 @@ class StateHandler(object): self._client = client self.marshal = lambda obj: json.dumps(obj) self.demarshal = lambda obj: json.loads(obj) - response = self._client.get_state() + response = self._client.get_storage() if response['result'] == 'success': self.state_ = response['state'] self._modified_entries = set() # type: Set[Text] @@ -85,7 +85,7 @@ class StateHandler(object): # type: () -> None state_update = {'state': {key: self.state_[key] for key in self._modified_entries}} if state_update: - response = self._client.update_state(state_update) + response = self._client.update_storage(state_update) if response['result'] == 'success': self._modified_entries.clear() else: diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index 3d76e09..0f5ca58 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) self.mock_client = MagicMock() - self.mock_client.get_state.return_value = {'result': 'success', 'state': {}} + self.mock_client.get_storage.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}