コード例 #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
ファイル: test_preferences.py プロジェクト: discentem/autopkg
 def test_set_pref_mac_files(self, mock_open, mock_write_file, mock_set_macos_pref):
     """Preferences().set_pref should write file on macOS and read_file() used."""
     self.mock_platform.return_value = "darwin"
     fake_prefs = Preferences()
     fake_prefs.read_file("fake_config_file")
     mock_open.assert_called()
     fake_prefs.set_pref("TEST_KEY", "fake_value")
     mock_write_file.assert_called()
     mock_set_macos_pref.assert_not_called()
     value = fake_prefs.get_pref("TEST_KEY")
     self.assertEqual(value, "fake_value")