Example #1
0
 def test_set_pref_nonmac(self, mock_ismac):
     """set_pref should change the prefs object."""
     mock_ismac.return_value = False
     fake_prefs = autopkglib.Preferences()
     fake_prefs.set_pref("TEST_KEY", "fake_value")
     value = fake_prefs.get_pref("TEST_KEY")
     self.assertEqual(value, "fake_value")
Example #2
0
 def test_read_file_fills_prefs(self, mock_file, mock_ckl):
     """read_file should populate the prefs object."""
     mock_ckl.return_value = []
     fake_prefs = autopkglib.Preferences()
     fake_prefs.read_file("fake_filepath")
     value = fake_prefs.get_all_prefs()
     self.assertEqual(value, json.loads(self.good_json))
Example #3
0
 def test_parse_file_reads_json(self, mock_file):
     """Parsing a JSON file should produce a dictionary."""
     fake_prefs = autopkglib.Preferences()
     value = fake_prefs._parse_json_or_plist_file("fake_filepath")
     self.assertEqual(value, json.loads(self.good_json))
Example #4
0
 def test_parse_file_is_empty_by_default(self):
     """Parsing a non-existent file should return an empty dict."""
     fake_prefs = autopkglib.Preferences()
     value = fake_prefs._parse_json_or_plist_file("fake_filepath")
     self.assertEqual(value, {})
Example #5
0
 def test_get_macos_pref_returns_value(self, mock_cav):
     """get_macos_pref should return a value."""
     mock_cav.return_value = "FakeValue"
     fake_prefs = autopkglib.Preferences()
     value = fake_prefs._get_macos_pref("fake")
     self.assertEqual(value, "FakeValue")
Example #6
0
 def test_prefs_object_is_empty_by_default(self, mock_ckl):
     """A new Preferences object should be empty."""
     mock_ckl.return_value = []
     fake_prefs = autopkglib.Preferences()
     self.assertEqual(fake_prefs.get_all_prefs(), {})
Example #7
0
 def test_prefs_object_is_empty_on_nonmac(self, mock_ismac):
     """A new Preferences object on non-macOS should be empty."""
     mock_ismac.return_value = False
     fake_prefs = autopkglib.Preferences()
     self.assertEqual(fake_prefs.get_all_prefs(), {})
Example #8
0
 def test_prefs_object_is_empty_by_default(self):
     """A new Preferences object should be empty."""
     fake_prefs = autopkglib.Preferences()
     self.assertEqual(fake_prefs.get_all_prefs(), {})