#345 Handle on 'docker' advisories in RebuildImagesOnImageAdvisoryChange.
Merged 3 months ago by jkaluza. Opened 3 months ago by jkaluza.
jkaluza/freshmaker spec-fix  into  master

@@ -36,7 +36,14 @@ 

      name = 'RebuildImagesOnImageAdvisoryChange'

  

      def can_handle(self, event):

-         return isinstance(event, ErrataAdvisoryStateChangedEvent)

+         if not isinstance(event, ErrataAdvisoryStateChangedEvent):

+             return False

+ 

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

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

+             return False

+ 

+         return True

  

      @fail_event_on_handler_exception

      def handle(self, event):

@@ -42,6 +42,16 @@ 

          self.handler = RebuildImagesOnImageAdvisoryChange()

          self.db_event = MagicMock()

  

+     def test_can_handle(self):

+         self.event.advisory.content_types = ["docker"]

+         ret = self.handler.can_handle(self.event)

+         self.assertTrue(ret)

+ 

+     def test_can_handle_non_docker_advisory(self):

+         self.event.advisory.content_types = ["rpm"]

+         ret = self.handler.can_handle(self.event)

+         self.assertFalse(ret)

+ 

      @patch.object(freshmaker.conf, 'handler_build_whitelist', new={

          'RebuildImagesOnImageAdvisoryChange': {

              "image": {"advisory_state": "SHIPPED_LIVE"}

Other content_types don't make sense for this handler.

Pull-Request has been merged by jkaluza

3 months ago