#347 Allow running Bob handler as result of manual event to test it out.
Merged 6 months ago by jkaluza. Opened 6 months ago by jkaluza.
jkaluza/freshmaker spec-fix  into  master

@@ -27,7 +27,8 @@ 

  from freshmaker.models import Event

  from freshmaker.errata import Errata

  from freshmaker.pulp import Pulp

- from freshmaker.events import ErrataAdvisoryStateChangedEvent

+ from freshmaker.events import (ErrataAdvisoryStateChangedEvent,

+                                ManualRebuildWithAdvisoryEvent)

  from freshmaker.handlers import ContainerBuildHandler, fail_event_on_handler_exception

  from freshmaker.types import EventState

  

@@ -36,7 +37,8 @@ 

      name = 'RebuildImagesOnImageAdvisoryChange'

  

      def can_handle(self, event):

-         if not isinstance(event, ErrataAdvisoryStateChangedEvent):

+         if (not isinstance(event, ErrataAdvisoryStateChangedEvent) and

+                 not isinstance(event, ManualRebuildWithAdvisoryEvent)):

              return False

  

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

@@ -24,7 +24,8 @@ 

  

  import freshmaker

  from freshmaker.errata import ErrataAdvisory

- from freshmaker.events import ErrataAdvisoryStateChangedEvent

+ from freshmaker.events import (ErrataAdvisoryStateChangedEvent,

+                                ManualRebuildWithAdvisoryEvent)

  from freshmaker.handlers.bob import RebuildImagesOnImageAdvisoryChange

  from tests import helpers

  

@@ -47,6 +48,16 @@ 

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

          self.assertTrue(ret)

  

+     def test_can_handle_manual_event(self):

+         event = ManualRebuildWithAdvisoryEvent(

+             "123",

+             ErrataAdvisory(123, "RHBA-2017", "SHIPPED_LIVE", ["docker"],

+                            security_impact="",

+                            product_short_name="product"),

+             [])

+         ret = self.handler.can_handle(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)

@@ -85,8 +96,8 @@ 

          self.handler.rebuild_images_depending_on_advisory(self.db_event, 123)

  

          get_docker_repo_tags.assert_called_once_with(123)

-         get_docker_repository_name.assert_has_calls([

-             call("bar-526"), call("foo-526")])

+         get_docker_repository_name.assert_any_call("bar-526")

+         get_docker_repository_name.assert_any_call("foo-526")

          requests_get.assert_any_call(

              'http://localhost/update_children/scl/foo-526',

              headers={'Authorization': 'Bearer x'})

no initial comment

Commit 701f4c9 fixes this pull-request

Pull-Request has been merged by jkaluza

6 months ago

Pull-Request has been merged by jkaluza

6 months ago