test_02_MappedIMAP.py 2.7 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 random
  17. import unittest
  18. import logging
  19. import os, sys
  20. from test.OLItest import OLITestLib
  21. # Things need to be setup first, usually setup.py initializes everything.
  22. # but if e.g. called from command line, we take care of default values here:
  23. if not OLITestLib.cred_file:
  24. OLITestLib(cred_file='./test/credentials.conf', cmd='./offlineimap.py')
  25. def setUpModule():
  26. logging.info("Set Up test module %s" % __name__)
  27. tdir = OLITestLib.create_test_dir(suffix=__name__)
  28. def tearDownModule():
  29. logging.info("Tear Down test module")
  30. OLITestLib.delete_test_dir()
  31. #Stuff that can be used
  32. #self.assertEqual(self.seq, range(10))
  33. # should raise an exception for an immutable sequence
  34. #self.assertRaises(TypeError, random.shuffle, (1,2,3))
  35. #self.assertTrue(element in self.seq)
  36. #self.assertFalse(element in self.seq)
  37. class TestBasicFunctions(unittest.TestCase):
  38. #@classmethod
  39. #def setUpClass(cls):
  40. #This is run before all tests in this class
  41. # cls._connection = createExpensiveConnectionObject()
  42. #@classmethod
  43. #This is run after all tests in this class
  44. #def tearDownClass(cls):
  45. # cls._connection.destroy()
  46. # This will be run before each test
  47. #def setUp(self):
  48. # self.seq = range(10)
  49. def test_01_MappedImap(self):
  50. """Tests if a MappedIMAP sync can be invoked without exceptions
  51. Cleans existing remote test folders. Then syncs all "OLItest*
  52. (specified in the default config) to our local IMAP (Gmail). The
  53. result should be 0 folders and 0 mails."""
  54. pass #TODO
  55. #OLITestLib.delete_remote_testfolders()
  56. #code, res = OLITestLib.run_OLI()
  57. #self.assertEqual(res, "")
  58. #boxes, mails = OLITestLib.count_maildir_mails('')
  59. #self.assertTrue((boxes, mails)==(0,0), msg="Expected 0 folders and 0"
  60. # "mails, but sync led to {} folders and {} mails".format(
  61. # boxes, mails))