test_02_MappedIMAP.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright (C) 2012- Sebastian Spaeth & contributors
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. import unittest
  17. import logging
  18. from test.OLItest import OLITestLib
  19. # Things need to be setup first, usually setup.py initializes everything.
  20. # but if e.g. called from command line, we take care of default values here:
  21. if not OLITestLib.cred_file:
  22. OLITestLib(cred_file='./test/credentials.conf', cmd='./offlineimap.py')
  23. def setUpModule():
  24. logging.info("Set Up test module %s" % __name__)
  25. OLITestLib.create_test_dir(suffix=__name__)
  26. def tearDownModule():
  27. logging.info("Tear Down test module")
  28. OLITestLib.delete_test_dir()
  29. # Stuff that can be used
  30. # self.assertEqual(self.seq, range(10))
  31. # should raise an exception for an immutable sequence
  32. # self.assertRaises(TypeError, random.shuffle, (1,2,3))
  33. # self.assertTrue(element in self.seq)
  34. # self.assertFalse(element in self.seq)
  35. class TestBasicFunctions(unittest.TestCase):
  36. # @classmethod
  37. # def setUpClass(cls):
  38. # This is run before all tests in this class
  39. # cls._connection = createExpensiveConnectionObject()
  40. # @classmethod
  41. # This is run after all tests in this class
  42. # def tearDownClass(cls):
  43. # cls._connection.destroy()
  44. # This will be run before each test
  45. # def setUp(self):
  46. # self.seq = range(10)
  47. def test_01_MappedImap(self):
  48. """Tests if a MappedIMAP sync can be invoked without exceptions
  49. Cleans existing remote test folders. Then syncs all "OLItest*
  50. (specified in the default config) to our local IMAP (Gmail). The
  51. result should be 0 folders and 0 mails."""
  52. pass # TODO
  53. # OLITestLib.delete_remote_testfolders()
  54. # code, res = OLITestLib.run_OLI()
  55. # self.assertEqual(res, "")
  56. # boxes, mails = OLITestLib.count_maildir_mails('')
  57. # self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0"
  58. # "mails, but sync led to {} folders and {} mails".format(
  59. # boxes, mails))