Пример #1
0
 def test_read_file_fills_prefs(self, _mock_file):
     """read_file should populate the prefs object."""
     fake_prefs = Preferences()
     fake_prefs.read_file("fake_filepath")
     value = fake_prefs.get_all_prefs()
     self.assertEqual(value, plistlib.loads(TEST_PLIST_PREFS))
     self.assertEqual(fake_prefs.type, "plist")
Пример #2
0
 def test_init_prefs_files(self, _mock_open):
     """Preferences should load file-backed config on primary platforms."""
     for platform in self.PRIMARY_NON_MACOS_PLATFORMS:
         with self.subTest(platform=platform):
             self.mock_platform.return_value = platform
             prefs = Preferences()
             self.assertNotEqual(prefs.file_path, None)
             value = prefs.get_all_prefs()
             self.assertEqual(value, json.loads(TEST_JSON_PREFS))
             self.assertEqual(prefs.type, "json")
Пример #3
0
 def test_new_prefs_object_is_empty(self):
     """A new Preferences object should be empty with no config."""
     test_platforms = ["Darwin"]
     test_platforms += self.PRIMARY_NON_MACOS_PLATFORMS
     for platform in test_platforms:
         with self.subTest(platform=platform):
             self.mock_platform = platform
             fake_prefs = Preferences()
             self.assertEqual(fake_prefs.file_path, None)
             self.assertEqual(fake_prefs.type, None)
             self.assertEqual(fake_prefs.get_all_prefs(), {})