def test_publish_metadata_canceled(self): # Setup step = publish.PublishMetadataStep() self.publisher.add_child(step) mock_report_progress = mock.MagicMock() self.publisher._report_progress = mock_report_progress # Test self.publisher.cancel() step.process() # Verify self.assertEqual(0, mock_report_progress.call_count)
def test_publish_metadata(self, mock_get_units, mock_update): # Setup units = [self._generate_metadata_file_unit(dt, 'test-repo') for dt in ('A', 'B')] mock_get_units.return_value = units self.publisher.repo.content_unit_counts = {TYPE_ID_YUM_REPO_METADATA_FILE: len(units)} # Test step = publish.PublishMetadataStep() step.parent = self.publisher step.process() # Verify self.assertEquals(reporting_constants.STATE_COMPLETE, step.state) self.assertEquals(len(units), step.total_units) self.assertEquals(0, step.progress_failures) self.assertEquals(len(units), step.progress_successes) for u in units: data_type = u.unit_key['data_type'] path = os.path.join(self.working_dir, publish.REPO_DATA_DIR_NAME, data_type) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.islink(path)) self.assertTrue(os.path.exists( os.path.join(self.working_dir, 'repodata/%s' % data_type)))