示例#1
0
 def test_finalize_no_initialization(self):
     """
     Test to ensure that calling finalize before initialize_metadata() doesn't
     raise an exception
     """
     step = publish.PublishRpmStep(mock.Mock(package_dir=None))
     step.parent = self.publisher
     step.finalize()
示例#2
0
    def test_total_packages_in_repo_empty_repo(self):
        """
        in case the repo is empty and has no data in content_unit_counts, make sure this returns 0
        """
        repo = model.Repository(repo_id='foo')
        step = publish.PublishRpmStep(mock.Mock(package_dir=None))
        step.repo = repo.to_transfer_repo()

        total = step.total_packages_in_repo

        self.assertEqual(total, 0)
示例#3
0
    def test_process_unit_links_package_dir(self, mock_get_units, mock_update):
        unit = self._generate_rpm('one')
        mock_get_units.return_value = [unit]
        self.publisher.repo.content_unit_counts = {TYPE_ID_RPM: 1}
        package_dir = os.path.join(self.working_dir, 'packages')

        step = publish.PublishRpmStep(mock.Mock(package_dirs=[package_dir]))
        self.publisher.add_child(step)

        step.process()

        unit_path = os.path.join(package_dir, unit.unit_key['name'])
        self.assertTrue(os.path.exists(unit_path))
示例#4
0
    def test_total_packages_in_repo(self):
        """
        the "total_packages_in_repo" property should calculate a number based on content unit counts
        on the repo
        """
        repo = model.Repository(repo_id='foo')
        repo.content_unit_counts = {'rpm': 2, 'srpm': 3}
        step = publish.PublishRpmStep(mock.Mock(package_dir=None))
        step.repo = repo.to_transfer_repo()

        total = step.total_packages_in_repo

        self.assertEqual(total, 5)
示例#5
0
    def test_publish_rpms(self, mock_get_units, mock_update):
        self.publisher.repo.content_unit_counts = {TYPE_ID_RPM: 3}

        units = [self._generate_rpm(u) for u in ('one', 'two', 'tree')]
        mock_get_units.return_value = units

        step = publish.PublishRpmStep(mock.Mock(package_dirs=[]))
        step.parent = self.publisher

        step.process()

        for u in units:
            path = os.path.join(self.working_dir, u.unit_key['name'])
            self.assertTrue(os.path.exists(path))
            self.assertTrue(os.path.islink(path))

        self.assertTrue(os.path.exists(os.path.join(self.working_dir, 'repodata/filelists.xml.gz')))
        self.assertTrue(os.path.exists(os.path.join(self.working_dir, 'repodata/other.xml.gz')))
        self.assertTrue(os.path.exists(os.path.join(self.working_dir, 'repodata/primary.xml.gz')))