コード例 #1
0
 def test_load_settings__missing_subkey__is_populated(self):
     with tempfile.NamedTemporaryFile(mode='r+') as settings_file:
         settings = settings_loader.load_settings(settings_file)
         del engine_settings(settings)[0]['nickname']
         json.dump(settings, settings_file)
         settings_file.seek(0)
         self.assertEqual(settings_loader.load_default_settings(), settings_loader.load_settings(settings_file))
コード例 #2
0
 def test_load_settings__missing_key_to_dict__is_populated(self):
     with tempfile.NamedTemporaryFile(mode='r+') as settings_file:
         settings = settings_loader.load_settings(settings_file)
         del settings['data_directory']
         json.dump(settings, settings_file)
         settings_file.seek(0)
         self.assertEqual(settings_loader.load_default_settings(), settings_loader.load_settings(settings_file))
コード例 #3
0
 def test_default_settings__has_expected_keys(self):
     settings = settings_loader.load_default_settings()
     self.assertTrue('data_directory' in settings)
     self.assertTrue('engine_options_directory' in settings)
     self.assertTrue('engines' in settings)
     self.assertEqual(1, len(engine_settings(settings)))
     self.assertTrue('nickname' in engine_settings(settings)[0])
     self.assertTrue('path' in engine_settings(settings)[0])
コード例 #4
0
 def test_load_settings__use_defaults_false__after_save__loads_default_keys(self):
     with tempfile.NamedTemporaryFile(mode='r+') as settings_file:
         default_settings = settings_loader.load_default_settings()
         default_settings['data_directory'] = ''
         default_settings['engine_options_directory'] = ''
         settings = settings_loader.load_settings(settings_file, False)
         json.dump(settings, settings_file)
         settings_file.seek(0)
         self.assertEqual(default_settings, settings_loader.load_settings(settings_file, False))
コード例 #5
0
 def test_load_settings__use_defaults_false__empty_file__loads_default_keys(self):
     with tempfile.NamedTemporaryFile() as settings_file:
         default_settings = settings_loader.load_default_settings()
         default_settings['data_directory'] = ''
         default_settings['engine_options_directory'] = ''
         self.assertEqual(default_settings, settings_loader.load_settings(settings_file, False))
コード例 #6
0
 def test_load_settings__empty_file__loads_defaults(self):
     with tempfile.NamedTemporaryFile() as settings_file:
         default_settings = settings_loader.load_default_settings()
         self.assertEqual(default_settings, settings_loader.load_settings(settings_file))
コード例 #7
0
 def test_load_settings__after_save__default_values_are_populates(self):
     with tempfile.NamedTemporaryFile(mode='r+') as settings_file:
         settings = settings_loader.load_settings(settings_file, False)
         json.dump(settings, settings_file)
         settings_file.seek(0)
         self.assertEqual(settings_loader.load_default_settings(), settings_loader.load_settings(settings_file))