Don't hardcode any data file paths
[straw.git] / test / TestConfig.py
blob499f4301f4e7442936b233a7b1f1ca0034679041
1 # Test Config.py
4 import pygtk
5 import gobject
6 from mock import Mock
7 import nose
9 import os
11 from straw.Config import Config
13 class TestConfig:
14 def setUp(self):
15 self.mockPersistence = Mock( {
16 'save_option': None,
17 '__nonzero__' : 1
19 self.config = Config(self.mockPersistence)
21 def tearDown(self):
22 self.config = None
23 self.mockPersistence = None
25 def testProxy(self):
26 os.environ['http_proxy'] = 'http://localhost:3128'
27 self.config.initialize_proxy()
28 assert isinstance(self.config.proxy, Config.EnvironmentProxyConfig)
29 del os.environ['http_proxy']
30 self.config.initialize_proxy()
31 assert isinstance(self.config.proxy, Config.GconfProxyConfig)
33 def testPollFrequency(self):
34 def _cb(x): assert x is self.config
35 f = 18000
36 self.config.connect('refresh-changed', _cb)
37 self.config.poll_frequency = f
38 self.mockPersistence.expectParams(Config.OPTION_POLL_FREQUENCY, f)
39 assert self.config.poll_frequency == f
41 def testLastPoll(self):
42 last_poll = 24600
43 self.config.last_poll = last_poll
44 self.mockPersistence.expectParams(Config.OPTION_LAST_POLL, last_poll)
45 assert self.config.last_poll == last_poll
47 def testItemsStored(self):
48 def _cb(x): assert x is self.config
49 stored = 150
50 self.config.connect('items-stored-changed', _cb)
51 self.config.number_of_items_stored = stored
52 assert self.config.number_of_items_stored == stored
54 def testItemOrder(self):
55 def _cb(x): assert x is self.config
56 order = True
57 self.config.connect('item-order-changed', _cb)
58 self.config.item_order = order
59 assert self.config.item_order == order
61 def testOffline(self):
62 def _cb(x): assert x is self.config
63 offline = False
64 self.config.connect('offline-mode-changed', _cb)
65 self.config.offline = offline
66 assert self.config.offline == offline
68 # feel free to add more tests here ...