4 from cola
import serializer
5 from cola
import settings
8 class SettingsTestCase(unittest
.TestCase
):
9 """Tests the cola.settings module"""
11 self
._old
_rcfile
= settings
._rcfile
12 self
._rcfile
= helper
.tmp_path('colarc')
13 settings
._rcfile
= self
._rcfile
16 if os
.path
.exists(self
._rcfile
):
17 os
.remove(self
._rcfile
)
18 settings
._rcfile
= self
._old
_rcfile
21 settings
.SettingsManager
._settings
= None
22 return settings
.SettingsManager
.settings()
24 def test_model_helper(self
):
27 self
.assertTrue(a
is not b
)
29 def test_gui_save_restore(self
):
30 """Test saving and restoring gui state"""
32 model
.gui_state
['test-gui'] = {'foo':'bar'}
33 settings
.SettingsManager
.save()
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"""
43 model
.add_bookmark('test-bookmark')
44 settings
.SettingsManager
.save()
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__':