From: Menno Smits Date: Mon, 27 Jul 2015 23:07:51 +0000 (+1200) Subject: Clean ups for Gmail label quoting change X-Git-Tag: 1.0.0~1^2~61 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=9cb016f8c4f6af52389be87cacc91fd3de54c495;p=imapclient.git Clean ups for Gmail label quoting change - unit tests pass again - quoting is now tested - updated NEWS --- diff --git a/NEWS.rst b/NEWS.rst index 4361bd5..5a81ad3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,3 +1,12 @@ +======= + 1.0.0 +======= + +Other +----- + * Perform quoting of Gmail labels. Thanks to Pawel Sz for the fix. + + ====== 0.13 ====== diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index b53eced..b872117 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -779,7 +779,7 @@ class IMAPClient(object): attribute (eg. Gmail). """ return self._store(b'+X-GM-LABELS', messages, - self._normalise_label_list(labels), b'X-GM-LABELS') + self._normalise_labels(labels), b'X-GM-LABELS') def remove_gmail_labels(self, messages, labels): """Remove one or more *labels* from *messages*. @@ -793,7 +793,7 @@ class IMAPClient(object): attribute (eg. Gmail). """ return self._store(b'-X-GM-LABELS', messages, - self._normalise_label_list(labels), b'X-GM-LABELS') + self._normalise_labels(labels), b'X-GM-LABELS') def set_gmail_labels(self, messages, labels): """Set the *labels* for *messages*. @@ -807,7 +807,7 @@ class IMAPClient(object): attribute (eg. Gmail). """ return self._store(b'X-GM-LABELS', messages, - self._normalise_label_list(labels), b'X-GM-LABELS') + self._normalise_labels(labels), b'X-GM-LABELS') def delete_messages(self, messages): """Delete one or more *messages* from the currently selected @@ -1037,8 +1037,8 @@ class IMAPClient(object): folder_name = encode_utf7(folder_name) return _quote(folder_name) - def _normalise_label_list(self, labels): - return iter(self._imap._quote(l) for l in labels) + def _normalise_labels(self, labels): + return [_quote(l) for l in labels] def _quote(arg): diff --git a/imapclient/test/test_imapclient.py b/imapclient/test/test_imapclient.py index 4c2c7ca..6394093 100644 --- a/imapclient/test/test_imapclient.py +++ b/imapclient/test/test_imapclient.py @@ -399,16 +399,22 @@ class TestGmailLabels(IMAPClientTest): 444: [b'foo']}) def test_add(self): - self.client.add_gmail_labels(sentinel.messages, sentinel.labels) - self.client._store.assert_called_with(b'+X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS') + self.client.add_gmail_labels(sentinel.messages, ['foo', 'B"A"R']) + self.client._store.assert_called_with( + b'+X-GM-LABELS', sentinel.messages, + ['"foo"', '"B\\"A\\"R"'], b'X-GM-LABELS') def test_remove(self): - self.client.remove_gmail_labels(sentinel.messages, sentinel.labels) - self.client._store.assert_called_with(b'-X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS') + self.client.remove_gmail_labels(sentinel.messages, ['q\\ux']) + self.client._store.assert_called_with( + b'-X-GM-LABELS', sentinel.messages, + ['"q\\\\ux"'], b'X-GM-LABELS') def test_set(self): - self.client.set_gmail_labels(sentinel.messages, sentinel.labels) - self.client._store.assert_called_with(b'X-GM-LABELS', sentinel.messages, sentinel.labels, b'X-GM-LABELS') + self.client.set_gmail_labels(sentinel.messages, ['faz', 'baz']) + self.client._store.assert_called_with( + b'X-GM-LABELS', sentinel.messages, + ['"faz"', '"baz"'], b'X-GM-LABELS') class TestNamespace(IMAPClientTest):