예제 #1
0
 def test_unset_immutable_property(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     incoming_repo = {'name': "woof"}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual("woof", existing_repo['name'])
예제 #2
0
 def test_unset_mutable_property(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     incoming_repo = {'metadata_expire': 2000}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual(2000, existing_repo['metadata_expire'])
예제 #3
0
 def test_gpgcheck_is_mutable(self):
     update_action = RepoUpdateActionCommand()
     self._inject_mock_invalid_consumer()
     existing_repo = Repo('testrepo')
     existing_repo['gpgcheck'] = "0"
     incoming_repo = {'gpgcheck': "1"}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual("0", existing_repo['gpgcheck'])
 def test_mutable_property(self):
     update_action = RepoUpdateActionCommand()
     self._inject_mock_invalid_consumer()
     existing_repo = Repo("testrepo")
     existing_repo["metadata_expire"] = 1000
     incoming_repo = {"metadata_expire": 2000}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual(1000, existing_repo["metadata_expire"])
예제 #5
0
 def test_mutable_property_in_repo_but_not_in_cert(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['metadata_expire'] = 1000
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual(1000, existing_repo['metadata_expire'])
예제 #6
0
 def test_gpgcheck_is_mutable(self):
     update_action = RepoUpdateActionCommand()
     self._inject_mock_invalid_consumer()
     existing_repo = Repo('testrepo')
     existing_repo['gpgcheck'] = "0"
     incoming_repo = {'gpgcheck': "1"}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual("0", existing_repo['gpgcheck'])
예제 #7
0
 def test_set_immutable_property_now_empty(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['proxy_username'] = "******"
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertFalse("proxy_username" in list(existing_repo.keys()))
예제 #8
0
 def test_immutable_property(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['name'] = "meow"
     incoming_repo = {'name': "woof"}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual("woof", existing_repo['name'])
예제 #9
0
 def test_set_immutable_property_now_empty(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['proxy_username'] = "******"
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertFalse("proxy_username" in list(existing_repo.keys()))
예제 #10
0
 def test_immutable_property(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo("testrepo")
     existing_repo["name"] = "meow"
     incoming_repo = {"name": "woof"}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual("woof", existing_repo["name"])
예제 #11
0
 def test_mutable_property_in_repo_but_not_in_cert(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['metadata_expire'] = 1000
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     self.assertEqual(1000, existing_repo['metadata_expire'])
예제 #12
0
 def test_set_immutable_property_now_not_in_cert(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['proxy_username'] = "******"
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     # Immutable properties should be always be added/updated,
     # and removed if undefined in the new repo definition.
     self.assertFalse("proxy_username" in list(existing_repo.keys()))
예제 #13
0
 def test_mutable_property_is_server(self):
     update_action = RepoUpdateActionCommand()
     self._inject_mock_invalid_consumer()
     existing_repo = Repo('testrepo')
     server_val_repo = Repo('servertestrepo')
     existing_repo['metadata_expire'] = 1000
     server_val_repo['metadata_expire'] = 1000
     incoming_repo = {'metadata_expire': 2000}
     update_action.update_repo(existing_repo, incoming_repo, server_val_repo)
     self.assertEqual(2000, existing_repo['metadata_expire'])
예제 #14
0
 def test_overrides_trump_existing(self):
     update_action = RepoUpdateActionCommand()
     update_action.overrides = {'x': {'gpgcheck': 'blah'}}
     values = [('gpgcheck', 'original'), ('gpgkey', 'some_key')]
     old_repo = Repo('x', values)
     new_repo = Repo(old_repo.id, values)
     update_action._set_override_info(new_repo)
     self.assertEqual('original', old_repo['gpgcheck'])
     update_action.update_repo(old_repo, new_repo)
     self.assertEqual('blah', old_repo['gpgcheck'])
     self.assertEqual('some_key', old_repo['gpgkey'])
예제 #15
0
 def test_overrides_trump_existing(self):
     update_action = RepoUpdateActionCommand()
     update_action.overrides = {"x": {"gpgcheck": "blah"}}
     values = [("gpgcheck", "original"), ("gpgkey", "some_key")]
     old_repo = Repo("x", values)
     new_repo = Repo(old_repo.id, values)
     update_action._set_override_info(new_repo)
     self.assertEquals("original", old_repo["gpgcheck"])
     update_action.update_repo(old_repo, new_repo)
     self.assertEquals("blah", old_repo["gpgcheck"])
     self.assertEquals("some_key", old_repo["gpgkey"])
예제 #16
0
 def test_set_mutable_property_now_not_in_cert(self):
     self._inject_mock_invalid_consumer()
     update_action = RepoUpdateActionCommand()
     existing_repo = Repo('testrepo')
     existing_repo['metadata_expire'] = "blah"
     incoming_repo = {}
     update_action.update_repo(existing_repo, incoming_repo)
     # re comments in repolib
     # Mutable properties should be added if not currently defined,
     # otherwise left alone.
     self.assertTrue("metadata_expire" in list(existing_repo.keys()))
예제 #17
0
 def test_non_default_override_removed_deleted(self):
     '''
     Test that overrides for values that aren't found in Repo.PROPERTIES are
     removed from redhat.repo once the override is removed
     '''
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {'x': {'somekey': 'someval'}}
     update_action.overrides = {}
     old_repo = Repo('x', [('somekey', 'someval')])
     new_repo = Repo(old_repo.id, [])
     update_action._set_override_info(new_repo)
     update_action.update_repo(old_repo, new_repo)
     self.assertFalse('somekey' in old_repo)
예제 #18
0
 def test_non_default_overrides_added_to_existing(self):
     '''
     Test that overrides for values that aren't found in Repo.PROPERTIES are written
     to existing repos
     '''
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {}
     update_action.overrides = {'x': {'somekey': 'someval'}}
     old_repo = Repo('x', [])
     new_repo = Repo(old_repo.id, [])
     update_action._set_override_info(new_repo)
     update_action.update_repo(old_repo, new_repo)
     self.assertEqual('someval', old_repo['somekey'])
예제 #19
0
 def test_overrides_removed_and_edited(self):
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {'x': {'gpgcheck': 'override_value'}}
     update_action.overrides = {}
     old_repo = Repo('x', [('gpgcheck', 'hand_edit'), ('gpgkey', 'some_key')])
     new_repo = Repo(old_repo.id, [('gpgcheck', 'original'), ('gpgkey', 'some_key')])
     update_action._set_override_info(new_repo)
     # The value from the current repo file (with the old hand edit) should exist pre-update
     self.assertEqual('hand_edit', old_repo['gpgcheck'])
     update_action.update_repo(old_repo, new_repo)
     # Because the current value doesn't match the override, we don't modify it
     self.assertEqual('hand_edit', old_repo['gpgcheck'])
     self.assertEqual('some_key', old_repo['gpgkey'])
예제 #20
0
 def test_overrides_removed_revert_to_default(self):
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {'x': {'gpgcheck': 'blah'}}
     update_action.overrides = {}
     old_repo = Repo('x', [('gpgcheck', 'blah'), ('gpgkey', 'some_key')])
     new_repo = Repo(old_repo.id, [('gpgcheck', 'original'), ('gpgkey', 'some_key')])
     update_action._set_override_info(new_repo)
     # The value from the current repo file (with the old override) should exist pre-update
     self.assertEqual('blah', old_repo['gpgcheck'])
     update_action.update_repo(old_repo, new_repo)
     # Because the override has been removed, the value is reset to the default
     self.assertEqual('original', old_repo['gpgcheck'])
     self.assertEqual('some_key', old_repo['gpgkey'])
예제 #21
0
 def test_overrides_removed_revert_to_default(self):
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {"x": {"gpgcheck": "blah"}}
     update_action.overrides = {}
     old_repo = Repo("x", [("gpgcheck", "blah"), ("gpgkey", "some_key")])
     new_repo = Repo(old_repo.id, [("gpgcheck", "original"), ("gpgkey", "some_key")])
     update_action._set_override_info(new_repo)
     # The value from the current repo file (with the old override) should exist pre-update
     self.assertEquals("blah", old_repo["gpgcheck"])
     update_action.update_repo(old_repo, new_repo)
     # Because the override has been removed, the value is reset to the default
     self.assertEquals("original", old_repo["gpgcheck"])
     self.assertEquals("some_key", old_repo["gpgkey"])
예제 #22
0
 def test_overrides_removed_and_edited(self):
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {"x": {"gpgcheck": "override_value"}}
     update_action.overrides = {}
     old_repo = Repo("x", [("gpgcheck", "hand_edit"), ("gpgkey", "some_key")])
     new_repo = Repo(old_repo.id, [("gpgcheck", "original"), ("gpgkey", "some_key")])
     update_action._set_override_info(new_repo)
     # The value from the current repo file (with the old hand edit) should exist pre-update
     self.assertEquals("hand_edit", old_repo["gpgcheck"])
     update_action.update_repo(old_repo, new_repo)
     # Because the current value doesn't match the override, we don't modify it
     self.assertEquals("hand_edit", old_repo["gpgcheck"])
     self.assertEquals("some_key", old_repo["gpgkey"])
예제 #23
0
 def test_non_default_overrides_added_to_existing(self):
     """
     Test that overrides for values that aren't found in Repo.PROPERTIES are written
     to existing repos
     """
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {}
     update_action.overrides = {"x": {"somekey": "someval"}}
     old_repo = Repo("x", [])
     new_repo = Repo(old_repo.id, [])
     update_action._set_override_info(new_repo)
     update_action.update_repo(old_repo, new_repo)
     self.assertEquals("someval", old_repo["somekey"])
예제 #24
0
 def test_non_default_override_removed_deleted(self):
     """
     Test that overrides for values that aren't found in Repo.PROPERTIES are
     removed from redhat.repo once the override is removed
     """
     update_action = RepoUpdateActionCommand()
     update_action.written_overrides.overrides = {"x": {"somekey": "someval"}}
     update_action.overrides = {}
     old_repo = Repo("x", [("somekey", "someval")])
     new_repo = Repo(old_repo.id, [])
     update_action._set_override_info(new_repo)
     update_action.update_repo(old_repo, new_repo)
     self.assertFalse("somekey" in old_repo)