Exemplo n.º 1
0
 def test_merge_settings(self):
     SettingsMigrator(self.settings_cfg, self.user_cfg).merge()
     SettingsMigrator(self.settings_cfg, self.user_cfg).merge()
     content = self._read_settings_file_content(self.user_cfg)
     line_count = len(content.splitlines())
     self.assertEquals(line_count, 33,
                       "line count should be 33 was %s" % line_count)
Exemplo n.º 2
0
 def test_merge_fails_reasonably_when_settings_file_is_read_only(self):
     try:
         SettingsMigrator(self.settings_path, self.read_only_path).merge()
     except RuntimeError as e:
         self.assertTrue(str(e).startswith('Could not open'))
     else:
         raise AssertionError('merging read-only file succeeded')
Exemplo n.º 3
0
 def test_merge_when_new_settings_in_defaults(self):
     self._write_settings("foo = 'bar'\nhello = 'world'\nnew = 'value'",
                          self.settings_path)
     self._write_settings("foo = 'new value'\nhello = 'world'",
                          self.user_settings_path)
     SettingsMigrator(self.settings_path, self.user_settings_path).merge()
     self._check_content(
         {
             'foo': 'new value',
             'hello': 'world',
             'new': 'value'
         }, False)
Exemplo n.º 4
0
 def test_merge_fails_reasonably_when_settings_file_is_read_only(self):
     try:
         SettingsMigrator(self.settings_path, self.read_only_path).merge()
     except RuntimeError, e:
         self.assertTrue(str(e).startswith('Could not open'))
Exemplo n.º 5
0
 def test_merge_when_user_settings_are_changed(self):
     self._write_settings("foo = 'new value'\nhello = 'world'",
                          self.user_settings_path)
     SettingsMigrator(self.settings_path, self.user_settings_path).merge()
     self._check_content({'foo': 'new value', 'hello': 'world'}, False)
Exemplo n.º 6
0
 def test_merge_when_no_user_settings(self):
     SettingsMigrator(self.settings_path, self.user_settings_path).merge()
     self._check_content({'foo': 'bar', 'hello': 'world'}, False)