models.main: Add a serialilzer to run generate_remote_helpers()
[git-cola.git] / test / test_cola_settings.py
blobbd8a4e0e761fd77943f020a3581ae89b8c6dd3a4
1 import unittest
2 import os
4 from cola import serializer
5 from cola import settings
6 import helper
8 class SettingsTestCase(unittest.TestCase):
9 """Tests the cola.settings module"""
10 def setUp(self):
11 self._old_rcfile = settings._rcfile
12 self._rcfile = helper.tmp_path('colarc')
13 settings._rcfile = self._rcfile
15 def tearDown(self):
16 if os.path.exists(self._rcfile):
17 os.remove(self._rcfile)
18 settings._rcfile = self._old_rcfile
20 def model(self):
21 settings.SettingsManager._settings = None
22 return settings.SettingsManager.settings()
24 def test_model_helper(self):
25 a = self.model()
26 b = self.model()
27 self.assertTrue(a is not b)
29 def test_gui_save_restore(self):
30 """Test saving and restoring gui state"""
31 model = self.model()
32 model.gui_state['test-gui'] = {'foo':'bar'}
33 settings.SettingsManager.save()
35 model = self.model()
36 state = model.gui_state.get('test-gui', {})
37 self.assertTrue('foo' in state)
38 self.assertEqual(state['foo'], 'bar')
40 def test_bookmarks_save_restore(self):
41 """Test the bookmark save/restore feature"""
42 model = self.model()
43 model.add_bookmark('test-bookmark')
44 settings.SettingsManager.save()
45 model = self.model()
46 bookmarks = model.bookmarks
47 self.assertEqual(len(bookmarks), 1)
48 self.assertTrue('test-bookmark' in bookmarks)
50 model.remove_bookmark('test-bookmark')
51 bookmarks = model.bookmarks
52 self.assertEqual(len(bookmarks), 0)
53 self.assertFalse('test-bookmark' in bookmarks)
55 if __name__ == '__main__':
56 unittest.main()