]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Clean ups for Gmail label quoting change
authorMenno Smits <menno@freshfoo.com>
Mon, 27 Jul 2015 23:07:51 +0000 (11:07 +1200)
committerMenno Smits <menno@freshfoo.com>
Mon, 27 Jul 2015 23:07:51 +0000 (11:07 +1200)
- unit tests pass again
- quoting is now tested
- updated NEWS

NEWS.rst
imapclient/imapclient.py
imapclient/test/test_imapclient.py

index 4361bd51e0d2a4d6d8247fcfe1df339beebe42a1..5a81ad34cddf4a6a42a9d57252e4adfe10d627b0 100644 (file)
--- 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
 ======
index b53eced5fcad2950e31f281fe43bdee48da22554..b872117c3984aec071b751e925280597e5319734 100644 (file)
@@ -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):
index 4c2c7ca020481f53c0afd56010c63ac5f2c29107..6394093766a6c489e0a0eff2a36e153749fed70d 100644 (file)
@@ -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):