diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_email_server.py | 17 | ||||
-rw-r--r-- | test/test_purge_obsolete.py | 43 |
2 files changed, 17 insertions, 43 deletions
diff --git a/test/test_email_server.py b/test/test_email_server.py new file mode 100644 index 0000000..3be9824 --- /dev/null +++ b/test/test_email_server.py @@ -0,0 +1,17 @@ +import unittest +from unittest import mock + +import archive_folder + + +class TestEmailServer(unittest.TestCase): + + # Ok, data = box.login(username, password) + # Ok, data = box.capability() + + @mock.patch.object(archive_folder.imaplib, 'IMAP4_SSL', autospec=True) + def test_server_initialization(self, mock_imapobj): + mock_imapobj.login.return_value = ('OK', 'FAKED success') + host = 'fakehost' + box = archive_folder.EmailServer(host, 'FakeArchive') + mock_imapobj.assert_called_with(host) diff --git a/test/test_purge_obsolete.py b/test/test_purge_obsolete.py deleted file mode 100644 index c4d1ec9..0000000 --- a/test/test_purge_obsolete.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import division -import unittest - -class SimpleDateTest(unittest.TestCase): - def setUp(self): - from purgeObsolete import SimpleDate - - def runInnerTest(self): - threeMonthAgo = date.today() - JD3MAgo = GregorianCalendar(threeMonthAgo.year, - threeMonthAgo.month-1, - threeMonthAgo.day,0,0) - formatter = SimpleDateFormat("yyyy-MM-dd",Locale.US); - JD3MAgoStr = formatter.format(JD3MAgo.getTime()) - self.assertEqual(str(threeMonthAgo),JD3MAgoStr) - - def runTest(self): - pass - -class ArchivedStoreTest(unittest.TestCase): - def setUp(self): - from purgeObsolete import ArchivedStore - self.store = ArchivedStore(paramServer="zimbra") - - def tearDown(self): - self.store.store.close() - - def testConnect(self): - folderList = self.store.store.getDefaultFolder().list("*") - self.assertEqual(len(folderList)>0,True) - - def testOpeningFolder(self): - from purgeObsolete import ArchivedFolder - folder = ArchivedFolder(self.store,"INBOX/bugzilla/xgl") - self.assertEqual(folder.folder.getMessageCount() > 0,True) - - def runTest(self): - self.testConnect() - self.testOpeningFolder() - -if __name__=="__main__": - unittest.main() |