From feb7a39e5846d98d5cf5c3d35eaf6c09fcf2cd51 Mon Sep 17 00:00:00 2001 From: Menno Smits Date: Fri, 4 May 2012 13:40:56 +0100 Subject: [PATCH] added some more namespace tests to finish off #63 --- imapclient/test/test_imapclient.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/imapclient/test/test_imapclient.py b/imapclient/test/test_imapclient.py index a63b1cb..096bf0d 100644 --- a/imapclient/test/test_imapclient.py +++ b/imapclient/test/test_imapclient.py @@ -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() -- 2.43.0