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')
15 class ConfigTestCase(unittest
.TestCase
):
16 def testPollFrequency(self
):
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
)
23 self
.assertEqual(poll_frequency
, config
.get_poll_frequency())
25 def testLastPoll(self
):
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
)
32 self
.assertEqual(last_poll
, config
.get_last_poll())
34 def testItemsStored(self
):
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
)
41 self
.assertEqual(stored
, config
.get_number_of_items_stored())
43 def testItemOrder(self
):
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
)
50 self
.assertEqual(order
, config
.get_item_order())
52 def testOffline(self
):
55 mock
.expects(pmock
.once()).save_option(pmock
.eq("/general/offline"),pmock
.eq(offline
))
56 config
= Config
.Config(mock
)
57 config
.set_offline(offline
)
59 self
.assertEqual(offline
, config
.get_offline())
61 # feel free to add more tests here ...
64 suite
= unittest
.makeSuite(ConfigTestCase
, 'test')
67 if __name__
== '__main__':