コード例 #1
0
    def test_publish_distribution_files_error(self, mock_symlink):
        unit = self._generate_distribution_unit('one')
        mock_symlink.side_effect = Exception('Test Error')
        step = publish.PublishDistributionStep()
        step.parent = self.publisher

        self.assertRaises(Exception, step._publish_distribution_files, unit)
コード例 #2
0
 def test_publish_distribution_packages_link_with_packagedir_equals_packages(self):
     unit = self._generate_distribution_unit('one', {'packagedir': 'Packages'})
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_packages_link(unit)
     packages_dir = os.path.join(self.publisher.repo.working_dir, 'Packages')
     self.assertEquals(packages_dir, step.package_dirs[0])
コード例 #3
0
    def _perform_treeinfo_success_test(self, treeinfo_name, mock_symlink):
        unit = self._generate_distribution_unit('one')
        file_name = os.path.join(unit.storage_path, treeinfo_name)
        open(file_name, 'a').close()
        target_directory = os.path.join(self.publisher.repo.working_dir, treeinfo_name)
        step = publish.PublishDistributionStep()
        step.parent = self.publisher
        step._publish_distribution_treeinfo(unit)

        mock_symlink.assert_called_once_with(file_name, target_directory)
コード例 #4
0
    def test_publish_distribution_files(self):
        unit = self._generate_distribution_unit('one')
        step = publish.PublishDistributionStep()
        step.parent = self.publisher
        step._publish_distribution_files(unit)

        content_file = os.path.join(unit.storage_path, 'images', 'boot.iso')
        created_link = os.path.join(self.publisher.repo.working_dir, "images", 'boot.iso')
        self.assertTrue(os.path.islink(created_link))
        self.assertEquals(os.path.realpath(created_link), os.path.realpath(content_file))
コード例 #5
0
 def test_publish_distribution_error(self, mock_get_units, mock_treeinfo, mock_update):
     self.publisher.repo.content_unit_counts = {TYPE_ID_DISTRO: 1}
     units = [self._generate_distribution_unit(u) for u in ('one', )]
     mock_get_units.return_value = units
     error = Exception('Test Error')
     mock_treeinfo.side_effect = error
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     self.assertRaises(Exception, step.process)
     self.assertEquals(step.progress_failures, 1)
コード例 #6
0
 def test_publish_distribution_packages_link_with_packagedir_delete_existing_packages(self):
     packages_dir = os.path.join(self.working_dir, 'Packages')
     old_directory = os.path.join(self.working_dir, "foo")
     os.mkdir(old_directory)
     PublishStep._create_symlink(old_directory, packages_dir)
     self.assertEquals(os.path.realpath(packages_dir), old_directory)
     unit = self._generate_distribution_unit('one', {'packagedir': 'Packages'})
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_packages_link(unit)
     self.assertFalse(os.path.islink(packages_dir))
コード例 #7
0
    def test_publish_distribution_treeinfo_error(self, mock_symlink):
        unit = self._generate_distribution_unit('one')
        file_name = os.path.join(unit.storage_path, 'treeinfo')
        open(file_name, 'a').close()
        target_directory = os.path.join(self.publisher.repo.working_dir, 'treeinfo')
        mock_symlink.side_effect = Exception("Test Error")
        step = publish.PublishDistributionStep()
        step.parent = self.publisher

        self.assertRaises(Exception, step._publish_distribution_treeinfo, unit)

        mock_symlink.assert_called_once_with(file_name, target_directory)
        self.assertEquals(0, step.progress_successes)
コード例 #8
0
    def test_publish_distribution(self, mock_get_units, mock_files, mock_treeinfo, mock_packages,
                                  mock_update):
        self.publisher.repo.content_unit_counts = {TYPE_ID_DISTRO: 1}
        units = [self._generate_distribution_unit(u) for u in ('one', )]
        mock_get_units.return_value = units

        step = publish.PublishDistributionStep()
        step.parent = self.publisher
        step.process()

        mock_files.assert_called_once_with(units[0])
        mock_treeinfo.assert_called_once_with(units[0])
        mock_packages.assert_called_once_with(units[0])
        self.assertEquals(step.state, reporting_constants.STATE_COMPLETE)
コード例 #9
0
    def test_publish_distribution_files_does_not_skip_repomd(self):
        """
        Assert that _publish_distribution_files() includes repomd.xml, in response to #1090534.

        https://bugzilla.redhat.com/show_bug.cgi?id=1090534
        """
        unit = self._generate_distribution_unit('one')
        unit.metadata['files'][0]['relativepath'] = 'repodata/repomd.xml'
        step = publish.PublishDistributionStep()
        step.parent = self.publisher
        # Let's put the file that should get linked to in the expected location
        repomd_path = os.path.join(self.working_dir, 'content', 'one', 'repodata', 'repomd.xml')
        self._touch(repomd_path)

        step._publish_distribution_files(unit)

        created_link = os.path.join(self.publisher.repo.working_dir, "repodata", 'repomd.xml')
        self.assertTrue(os.path.exists(created_link))
        # Make sure the symlink points to the correct path
        self.assertTrue(os.path.islink(created_link))
        self.assertEqual(os.readlink(created_link), repomd_path)
コード例 #10
0
 def test_publish_distribution_packages_link_error(self, mock_symlink):
     self._init_publisher()
     mock_symlink.side_effect = Exception("Test Error")
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     self.assertRaises(Exception, step._publish_distribution_packages_link)
コード例 #11
0
 def test_publish_distribution_packages_link_with_invalid_packagedir(self):
     self._init_publisher()
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     unit = self._generate_distribution_unit('one', {'packagedir': 'Server/../../foo'})
     self.assertRaises(InvalidValue, step._publish_distribution_packages_link, unit)
コード例 #12
0
 def test_publish_distribution_packages_link_with_packagedir(self):
     unit = self._generate_distribution_unit('one', {'packagedir': 'Server'})
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_packages_link(unit)
     self.assertEquals(os.path.join(self.working_dir, 'Server'), step.package_dirs[0])
コード例 #13
0
 def test_publish_distribution_files_no_files(self, mock_symlink):
     unit = self._generate_distribution_unit('one')
     unit.metadata.pop('files', None)
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_files(unit)
コード例 #14
0
 def test_publish_distribution_treeinfo_does_nothing_if_no_treeinfo_file(self):
     unit = self._generate_distribution_unit('one')
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._publish_distribution_treeinfo(unit)
     self.assertEquals(step.progress_successes + step.progress_failures, 0)
コード例 #15
0
 def test_publish_distribution_multiple_distribution(self):
     step = publish.PublishDistributionStep()
     step.parent = self.publisher
     step._get_total = mock.Mock(return_value=2)
     self.assertRaises(Exception, step.initialize)