fix proxy change detection
[straw.git] / test / TestConfig.py
blobe6c37f3760f9788669fadc5c68cf2816f27a461a
1 # Test Config.py
3 import unittest
4 import os
5 import sys
7 try:
8 import pmock
9 except ImportError:
10 sys.exit("You need python-mock (pmock, 0.3) to run this test. http://pmock.sf.net")
12 sys.path.insert(0, '../src/lib')
13 import Config
15 class ConfigTestCase(unittest.TestCase):
16 def testPollFrequency(self):
17 mock = pmock.Mock()
18 poll_frequency = 18000
19 mock.expects(pmock.once()).save_option(pmock.eq("/general/poll_frequency"),pmock.eq(poll_frequency))
20 config = Config.Config(mock)
21 config.set_poll_frequency(poll_frequency)
22 mock.verify()
23 self.assertEqual(poll_frequency, config.get_poll_frequency())
25 def testLastPoll(self):
26 mock = pmock.Mock()
27 last_poll = 24600
28 mock.expects(pmock.once()).save_option(pmock.eq("/general/last_poll"),pmock.eq(last_poll))
29 config = Config.Config(mock)
30 config.set_last_poll(last_poll)
31 mock.verify()
32 self.assertEqual(last_poll, config.get_last_poll())
34 def testItemsStored(self):
35 mock = pmock.Mock()
36 stored = 150
37 mock.expects(pmock.once()).save_option(pmock.eq("/general/number_of_items_stored"),pmock.eq(stored))
38 config = Config.Config(mock)
39 config.set_number_of_items_stored(stored)
40 mock.verify()
41 self.assertEqual(stored, config.get_number_of_items_stored())
43 def testItemOrder(self):
44 mock = pmock.Mock()
45 order = True
46 mock.expects(pmock.once()).save_option(pmock.eq("/general/item_order_newest"),pmock.eq(order))
47 config = Config.Config(mock)
48 config.set_item_order(order)
49 mock.verify()
50 self.assertEqual(order, config.get_item_order())
52 def testOffline(self):
53 mock = pmock.Mock()
54 offline = False
55 mock.expects(pmock.once()).save_option(pmock.eq("/general/offline"),pmock.eq(offline))
56 config = Config.Config(mock)
57 config.set_offline(offline)
58 mock.verify()
59 self.assertEqual(offline, config.get_offline())
61 # feel free to add more tests here ...
63 def suite():
64 suite = unittest.makeSuite(ConfigTestCase, 'test')
65 return suite
67 if __name__ == '__main__':
68 unittest.main()