def test_finalize_no_initialization(self): """ Test to ensure that calling finalize before initialize_metadata() doesn't raise an exception """ step = publish.PublishDrpmStep(mock.Mock()) step.parent = self.publisher step.finalize()
def test_process_unit_links_packages_dir(self, mock_symlink): step = publish.PublishDrpmStep(mock.Mock(package_dir='bar')) step.parent = self.publisher test_unit = self._generate_drpm('foo.rpm') test_unit.storage_path = '/bar' step.context = mock.Mock() step.dist_step.package_dirs = ['/bar'] step.process_main(test_unit) mock_symlink.assert_any_call('/bar', os.path.join(self.working_dir, 'drpms', 'foo.rpm'))
def test_process_unit(self, mock_symlink): step = publish.PublishDrpmStep(mock.Mock(package_dir=None)) step.parent = self.publisher test_unit = self._generate_drpm('foo.rpm') test_unit.storage_path = '/bar' step.context = mock.Mock() step.dist_step.package_dirs = [] step.process_main(test_unit) mock_symlink.assert_called_once_with('/bar', os.path.join(self.working_dir, 'drpms', 'foo.rpm')) step.context.add_unit_metadata.assert_called_once_with(test_unit)
def test_publish_drpms(self, mock_get_units, mock_update): self.publisher.repo.content_unit_counts = {TYPE_ID_DRPM: 2} units = [self._generate_drpm(u) for u in ('A', 'B')] mock_get_units.return_value = units package_dir_base = os.path.join(self.working_dir, 'bar') step = publish.PublishDrpmStep(mock.Mock(package_dirs=[package_dir_base])) step.parent = self.publisher step.process() for u in units: unit_path = os.path.join('drpms', u.unit_key['filename']) path = os.path.join(self.working_dir, unit_path) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.islink(path)) package_dir_path = os.path.join(package_dir_base, unit_path) self.assertTrue(os.path.exists(package_dir_path)) self.assertTrue(os.path.islink(package_dir_path)) self.assertTrue(os.path.exists( os.path.join(self.working_dir, 'repodata/prestodelta.xml.gz')))
def test_skip_if_no_units(self): step = publish.PublishDrpmStep(mock.Mock(package_dir=None)) step.parent = self.publisher self.assertTrue(step.is_skipped())