#349 Allow generating non-RPM manual advisory events. Do not run RebuildImagesOnRPMAdvisoryChange on non-RPM events.
Merged 6 months ago by jkaluza. Opened 6 months ago by jkaluza.
jkaluza/freshmaker spec-fix  into  master

@@ -46,7 +46,14 @@ 

      name = 'RebuildImagesOnRPMAdvisoryChange'

  

      def can_handle(self, event):

-         return isinstance(event, ErrataAdvisoryRPMsSignedEvent)

+         if not isinstance(event, ErrataAdvisoryRPMsSignedEvent):

+             return False

+ 

+         if 'rpm' not in event.advisory.content_types:

+             self.log_info('Skip non-RPM advisory %s.', event.advisory.errata_id)

+             return False

+ 

+         return True

  

      @fail_event_on_handler_exception

      def handle(self, event):

file modified
-7

@@ -262,13 +262,6 @@ 

          parser = FreshmakerManualRebuildParser()

          event = parser.parse_post_data(data)

  

-         # Check the the advisory is RPM advisory.

-         if 'rpm' not in event.advisory.content_types:

-             return json_error(

-                 400,

-                 'Bad Request',

-                 'Erratum {} is not a RPM advisory'.format(data['errata_id']))

- 

          # Store the event into database, so it gets the ID which we can return

          # to client sending this POST request. The client can then use the ID

          # to check for the event status.

@@ -224,7 +224,7 @@ 

      def test_can_handle_manual_rebuild_with_advisory_event(self):

          event = ManualRebuildWithAdvisoryEvent(

              "123",

-             ErrataAdvisory(123, "RHBA-2017", "REL_PREP", [],

+             ErrataAdvisory(123, "RHBA-2017", "REL_PREP", ["rpm"],

                             security_impact="",

                             product_short_name="product"),

              ["foo-container", "bar-container"])

file modified
-19

@@ -512,25 +512,6 @@ 

              'manual.rebuild',

              {'msg_id': 'manual_rebuild_123', u'errata_id': 1, 'dry_run': True})

  

-     @patch('freshmaker.parsers.internal.manual_rebuild.ErrataAdvisory.'

-            'from_advisory_id')

-     def test_not_rebuild_nonrpm_advisory(self, from_advisory_id):

-         from_advisory_id.return_value = ErrataAdvisory(

-             123, 'name', 'REL_PREP', ['docker'])

- 

-         resp = self.client.post('/api/1/builds/',

-                                 data=json.dumps({'errata_id': 1}),

-                                 content_type='application/json')

-         data = json.loads(resp.get_data(as_text=True))

- 

-         self.assertEqual(

-             {

-                 'status': 400,

-                 'error': 'Bad Request',

-                 'message': 'Erratum 1 is not a RPM advisory'

-             },

-             data)

- 

  

  class TestOpenIDCLogin(ViewBaseTest):

      """Test that OpenIDC login"""

no initial comment

rebased onto bd49c21

6 months ago

Commit 2b8f88a fixes this pull-request

Pull-Request has been merged by jkaluza

6 months ago

Pull-Request has been merged by jkaluza

6 months ago