#527 Store the Freshmaker event in the Lightblue class
Merged 4 years ago by mulaieva. Opened 4 years ago by mulaieva.
mulaieva/freshmaker event_id_add  into  master

@@ -397,8 +397,8 @@ 

          # content sets

          lb = LightBlue(server_url=conf.lightblue_server_url,

                         cert=conf.lightblue_certificate,

-                        private_key=conf.lightblue_private_key)

- 

+                        private_key=conf.lightblue_private_key,

+                        event_id=self.event.msg_id)

          # Check if we are allowed to rebuild unpublished images and clear

          # published and release_categories if so.

          if self.event.is_allowed(self, published=True):

file modified
+3 -1
@@ -428,7 +428,8 @@ 

  

      def __init__(self, server_url, cert, private_key,

                   verify_ssl=None,

-                  entity_versions=None):

+                  entity_versions=None,

+                  event_id=None):

          """Initialize LightBlue instance

  

          :param str server_url: URL used to call LightBlue APIs. It is
@@ -446,6 +447,7 @@ 

          """

          self.server_url = server_url.rstrip('/')

          self.api_root = '{}/rest/data'.format(self.server_url)

+         self.event_id = event_id

          if verify_ssl is None:

              self.verify_ssl = True

          else:

file modified
+15
@@ -29,12 +29,14 @@ 

  

  import freshmaker

  

+ from freshmaker.events import ErrataAdvisoryRPMsSignedEvent

  from freshmaker.lightblue import ContainerImage

  from freshmaker.lightblue import ContainerRepository

  from freshmaker.lightblue import LightBlue

  from freshmaker.lightblue import LightBlueRequestError

  from freshmaker.lightblue import LightBlueSystemError

  from freshmaker.utils import sorted_by_nvr

+ from freshmaker.errata import ErrataAdvisory

  from tests import helpers

  

  
@@ -754,12 +756,25 @@ 

               "target2", {"git_branch": "mybranch"}],

              ["git://pkgs.devel.redhat.com/rpms/repo-1#commit_hash1",

               "target1", {"git_branch": "mybranch"}]]

+         self.event = ErrataAdvisoryRPMsSignedEvent(

+             "123",

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

+                            security_impact="",

+                            product_short_name="product"))

  

      def tearDown(self):

          super(TestQueryEntityFromLightBlue, self).tearDown()

          self.patcher.unpatch_all()

          self.koji_read_config_patcher.stop()

  

+     @patch('os.path.exists', return_value=True)

+     def test_LightBlue_returns_event(self, exists):

+         lb = LightBlue(server_url=self.fake_server_url,

+                        cert=self.fake_cert_file,

+                        private_key=self.fake_private_key,

+                        event_id=self.event.msg_id)

+         assert lb.event_id == self.event.msg_id

+ 

      @patch('freshmaker.lightblue.requests.post')

      def test_find_container_images(self, post):

          post.return_value.status_code = http.client.OK

Store the Freshmaker event as a member variable in the LightBlue class.

The CI (specifically flake8) fails complaining about this line: we should remove it.

I'd just call it event_id instead of freshmaker_event_id since freshmaker seems redundant.

I believe you miss an additional change in freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
When instantiating the LightBlue class you should pass in there the id of the event. It should be available in there accessing self.event.
I believe this should be the only place.

rebased onto d03c8bf

4 years ago

rebased onto fcecbe9

4 years ago

rebased onto a489de4

4 years ago

rebased onto c6a601d

4 years ago

Flake8 complains about:
./tests/handlers/koji/test_rebuild_images_on_rpm_advisory_change.py:592:42: E231 missing whitespace after ','

I guess it's this line. (pagure doesn't show the real line so I'm not 100% sure, but it should be this one...)

Could you remove the WIP state if it's ready?

Mmm now that I see this test... don't hate me :D but maybe it would be more appropriate to add it to tests/test_lightblue.py since in the end we didn't add any test for _find_images_to_rebuild.

rebased onto c60a720

4 years ago

rebased onto 0b43d07

4 years ago

@gnaponie , take a look one more time. I'll remove WIP state after it :)

This if statement is not necessary.

rebased onto 9efe378

4 years ago

This if statement is not necessary.

Fixed

Commit 0577027 fixes this pull-request

Pull-Request has been merged by mulaieva

4 years ago

Pull-Request has been merged by mulaieva

4 years ago