def test_update_when_not_registered_and_existing_repo(self, mock_file):
        self._inject_mock_invalid_consumer()
        mock_file = mock_file.return_value
        mock_file.section.return_value = Repo("x", [("gpgcheck", "original"), ("gpgkey", "some_key")])

        def stub_content():
            return [Repo("x", [("gpgcheck", "new"), ("gpgkey", "new_key"), ("name", "test")])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_action.perform()

        written_repo = mock_file.update.call_args[0][0]
        self.assertEquals("original", written_repo["gpgcheck"])
        self.assertEquals("new_key", written_repo["gpgkey"])
    def test_update_when_not_registered_and_existing_repo(self, mock_file):
        self._inject_mock_invalid_consumer()
        mock_file = mock_file.return_value
        mock_file.section.return_value = Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_action.perform()

        written_repo = mock_file.update.call_args[0][0]
        self.assertEquals('original', written_repo['gpgcheck'])
        self.assertEquals('new_key', written_repo['gpgkey'])
Esempio n. 3
0
    def test_update_when_not_registered_and_existing_repo(self, mock_file):
        self._inject_mock_invalid_consumer()
        mock_file = mock_file.return_value
        mock_file.section.return_value = Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key'), ('name', 'test')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_action.perform()

        written_repo = mock_file.update.call_args[0][0]
        self.assertEquals('original', written_repo['gpgcheck'])
        self.assertEquals('new_key', written_repo['gpgkey'])
Esempio n. 4
0
    def test_update_when_repo_modified_on_mutable(self, mock_get_repo_file_classes):
        self._inject_mock_invalid_consumer()
        modified_repo = Repo('x', [('gpgcheck', 'unoriginal'), ('gpgkey', 'some_key')])
        server_repo = Repo('x', [('gpgcheck', 'original')])
        mock_file = MagicMock()
        mock_file.CONTENT_TYPES = [None]
        mock_file.fix_content = lambda x: x
        mock_file.section.side_effect = [modified_repo, server_repo]
        mock_class = MagicMock(return_value=mock_file)
        mock_get_repo_file_classes.return_value = [(mock_class, mock_class)]

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key'), ('name', 'test')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        current = update_action.perform()
        # confirming that the assessed value does not change when repo file
        # is different from the server value file.
        self.assertEqual('unoriginal', current.repo_updates[0]['gpgcheck'])

        # this is the ending server value file
        written_repo = mock_file.update.call_args[0][0]
        self.assertEqual('new', written_repo['gpgcheck'])
        self.assertEqual(None, written_repo['gpgkey'])
    def test_update_when_repo_not_modified_on_mutable(self, mock_file):
        self._inject_mock_invalid_consumer()
        mock_file = mock_file.return_value
        modified_repo = Repo('x', [('gpgcheck', 'original'),
                                   ('gpgkey', 'some_key')])
        server_repo = Repo('x', [('gpgcheck', 'original')])
        mock_file.section = MagicMock(side_effect=[modified_repo, server_repo])

        def stub_content():
            return [
                Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key'),
                           ('name', 'test')])
            ]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        current = update_action.perform()
        # confirming that the assessed value does change when repo file
        # is the same as the server value file.
        self.assertEqual('new', current.repo_updates[0]['gpgcheck'])

        # this is the ending server value file.
        written_repo = mock_file.update.call_args[0][0]
        self.assertEqual('new', written_repo['gpgcheck'])
        self.assertEqual(None, written_repo['gpgkey'])
    def test_update_when_new_repo(self, mock_file):
        mock_file = mock_file.return_value
        mock_file.section.return_value = None

        def stub_content():
            return [Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_report = update_action.perform()
        written_repo = mock_file.add.call_args[0][0]
        self.assertEqual('original', written_repo['gpgcheck'])
        self.assertEqual('some_key', written_repo['gpgkey'])
        self.assertEqual(1, update_report.updates())
Esempio n. 7
0
    def test_update_when_new_repo(self, mock_file):
        mock_file = mock_file.return_value
        mock_file.section.return_value = None

        def stub_content():
            return [Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_report = update_action.perform()
        written_repo = mock_file.add.call_args[0][0]
        self.assertEquals('original', written_repo['gpgcheck'])
        self.assertEquals('some_key', written_repo['gpgkey'])
        self.assertEquals(1, update_report.updates())
    def test_update_when_new_repo(self, mock_file):
        mock_file = mock_file.return_value
        mock_file.section.return_value = None

        def stub_content():
            return [Repo("x", [("gpgcheck", "original"), ("gpgkey", "some_key")])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_report = update_action.perform()
        written_repo = mock_file.add.call_args[0][0]
        self.assertEquals("original", written_repo["gpgcheck"])
        self.assertEquals("some_key", written_repo["gpgkey"])
        self.assertEquals(1, update_report.updates())
    def test_update_when_registered_and_existing_repo(self, mock_file):
        mock_file = mock_file.return_value
        mock_file.section.return_value = Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_action.override_supported = True
        update_report = update_action.perform()
        written_repo = mock_file.update.call_args[0][0]
        self.assertEquals('new', written_repo['gpgcheck'])
        self.assertEquals('new_key', written_repo['gpgkey'])
        self.assertEquals(1, update_report.updates())
    def test_update_when_registered_and_existing_repo(self, mock_file):
        mock_file = mock_file.return_value
        mock_file.section.return_value = Repo('x', [('gpgcheck', 'original'),
                                                    ('gpgkey', 'some_key')])

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_action.override_supported = True
        update_report = update_action.perform()
        written_repo = mock_file.update.call_args[0][0]
        self.assertEquals('new', written_repo['gpgcheck'])
        self.assertEquals('new_key', written_repo['gpgkey'])
        self.assertEquals(1, update_report.updates())
Esempio n. 11
0
    def test_update_when_new_repo(self, mock_get_repo_files):
        mock_file = MagicMock()
        mock_file.CONTENT_TYPES = [None]
        mock_file.fix_content = lambda x: x
        mock_file.section.return_value = None
        mock_get_repo_files.return_value = [(mock_file, mock_file)]

        def stub_content():
            return [Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_report = update_action.perform()
        written_repo = mock_file.add.call_args[0][0]
        self.assertEqual('original', written_repo['gpgcheck'])
        self.assertEqual('some_key', written_repo['gpgkey'])
        self.assertEqual(1, update_report.updates())
Esempio n. 12
0
    def test_update_when_new_repo(self, mock_get_repo_file_classes):
        mock_file = MagicMock()
        mock_file.CONTENT_TYPES = [None]
        mock_file.fix_content = lambda x: x
        mock_file.section.return_value = None
        mock_class = MagicMock(return_value=mock_file)
        mock_get_repo_file_classes.return_value = [(mock_class, mock_class)]

        def stub_content():
            return [Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        update_report = update_action.perform()
        written_repo = mock_file.add.call_args[0][0]
        self.assertEqual('original', written_repo['gpgcheck'])
        self.assertEqual('some_key', written_repo['gpgkey'])
        self.assertEqual(1, update_report.updates())
Esempio n. 13
0
    def test_update_when_repo_not_modified_on_mutable(self, mock_file):
        self._inject_mock_invalid_consumer()
        mock_file = mock_file.return_value
        modified_repo = Repo('x', [('gpgcheck', 'original'), ('gpgkey', 'some_key')])
        server_repo = Repo('x', [('gpgcheck', 'original')])
        mock_file.section = MagicMock(side_effect=[modified_repo, server_repo])

        def stub_content():
            return [Repo('x', [('gpgcheck', 'new'), ('gpgkey', 'new_key'), ('name', 'test')])]

        update_action = RepoUpdateActionCommand()
        update_action.get_unique_content = stub_content
        current = update_action.perform()
        # confirming that the assessed value does change when repo file
        # is the same as the server value file.
        self.assertEqual('new', current.repo_updates[0]['gpgcheck'])

        # this is the ending server value file.
        written_repo = mock_file.update.call_args[0][0]
        self.assertEqual('new', written_repo['gpgcheck'])
        self.assertEqual(None, written_repo['gpgkey'])