]> khamidou — GitHub mirrors - imapclient.git/commitdiff
added some more namespace tests to finish off #63
authorMenno Smits <menno@freshfoo.com>
Fri, 4 May 2012 12:40:56 +0000 (13:40 +0100)
committerMenno Smits <menno@freshfoo.com>
Fri, 4 May 2012 12:40:56 +0000 (13:40 +0100)
imapclient/test/test_imapclient.py

index a63b1cb91c17d951ab8536ed615811be00d90f1f..096bf0d11367d032285a5e1c4d436ccdd82101e3 100644 (file)
@@ -367,5 +367,29 @@ class TestGmailLabels(IMAPClientTest):
         self.client._store.assert_called_with('X-GM-LABELS', sentinel.messages, sentinel.labels)
 
 
+class TestNamespace(IMAPClientTest):
+
+    def set_return(self, value):
+        self.client._imap.namespace.return_value = ('OK', [value])
+
+    def test_simple(self):
+        self.set_return('(("FOO." "/")) NIL NIL')
+        self.assertEquals(self.client.namespace(), ((('FOO.', '/'),), None, None))
+
+    def test_other_only(self):
+        self.set_return('NIL NIL (("" "."))')
+        self.assertEquals(self.client.namespace(), (None, None, (("", "."),)))
+
+    def test_complex(self):
+        self.set_return('(("" "/")) '
+                        '(("~" "/")) '
+                        '(("#shared/" "/") ("#public/" "/")("#ftp/" "/")("#news." "."))')
+        self.assertEquals(self.client.namespace(), (
+            (("", "/"),),
+            (("~", "/"),),
+            (("#shared/", "/"), ("#public/", "/"), ("#ftp/", "/"), ("#news.", ".")),
+            ))
+
+
 if __name__ == '__main__':
     unittest.main()