def remove_bugs(advisory_id, bug_ids, remove_all, bug_tracker, noop): try: advisory = errata.Advisory(errata_id=advisory_id) except GSSError: exit_unauthenticated() if not advisory: raise ElliottFatalError(f"Error: Could not locate advisory {advisory_id}") try: attached_bug_ids = bug_tracker.advisory_bug_ids(advisory) if not remove_all: bug_ids = [b for b in bug_ids if b in attached_bug_ids] else: bug_ids = attached_bug_ids green_prefix(f"Found {len(bug_ids)} bugs attached to advisory: ") click.echo(f"{bug_ids}") if not bug_ids: return green_prefix(f"Removing bugs from advisory {advisory_id}..") bug_tracker.remove_bugs(advisory, bug_ids, noop) except ErrataException as ex: raise ElliottFatalError(getattr(ex, 'message', repr(ex)))
def test_attach_builds(self, addBuilds, echo, green_print): advisory = errata.Advisory(errata_id=123) advisory.attach_builds(unshipped_builds, 'image') self.assertEqual(addBuilds.call_count, 2) addBuilds.assert_any_call(buildlist=['image1-container-123', 'image2-container-456'], file_types={'image1-container-123': ['tar'], 'image2-container-456': ['tar']}, release='OSE-4.7-RHEL-8') addBuilds.assert_any_call(buildlist=['image3-container-789'], file_types={'image3-container-789': ['tar']}, release='ANOTHER_PV')
def test_attach_builds_verifies_valid_state(self, echo): """Verify error is raised when requesting unknown kind""" advisory = errata.Advisory(errata_id=123) with self.assertRaises(ValueError) as context: advisory.attach_builds(['build-1-123'], 'unkown_build_type') self.assertTrue("should be one of 'rpm' or 'image'" in context.exception.__str__())
def test_ensure_state_change_if_needed(self, setState, commit): """Verify attempt is made to set advisory state""" advisory = errata.Advisory(errata_id=123, errata_state='QE') advisory.ensure_state('NEW_FILES') setState.assert_called()
def test_ensure_state_untouched_if_not_necessary(self, setState): """Verify that advisory is untouched if desired state equals current state""" advisory = errata.Advisory(errata_id=123, errata_state='QE') advisory.ensure_state('QE') setState.assert_not_called()
def test_ensure_state_valid_advisory_state(self): """Verify error is raised if desired state is not a recognized state""" advisory = errata.Advisory(errata_id=123, errata_state='invalid_errata_status') with self.assertRaises(ValueError) as context: advisory.ensure_state('UnknownState') self.assertTrue('UnknownState' in context.exception.__str__())