#3 Add FedoraBodhiResult convention for Bodhi results
Merged 7 years ago by adamwill. Opened 7 years ago by adamwill.

@@ -28,6 +28,7 @@ 

  import fedfind.release

  

  # internal imports

+ from .base import Result

  from .prodmd import (ProductmdComposeResult, ProductmdImageResult)

  

  # pylint:disable=invalid-name
@@ -91,4 +92,25 @@ 

              # this happens if the expression find *no* images

              raise ValueError("Can't find image {0} in release {1}".format(self.filename, self.cid))

  

+ 

+ class FedoraBodhiResult(Result):

+     """Result from testing a Fedora Bodhi update. update is the

+     update ID.

+     """

+     def __init__(self, update, *args, **kwargs):

+         self.update = update

+         super(FedoraBodhiResult, self).__init__(*args, **kwargs)

+         self.conventions.append('fedora.bodhi')

+         self.extradata.update({

+             'item': self.update,

+             'type': 'bodhi_update',

+         })

+ 

+     def default_groups(self):

+         super(FedoraBodhiResult, self).default_groups()

+         url = 'https://bodhi.fedoraproject.org/updates/{0}'.format(self.update)

+         self.add_group('bodhi', self.update, ref_url=url)

+         if self.source:

+             self.add_group(self.source, self.update)

+ 

  # vim: set textwidth=120 ts=8 et sw=4:

file modified
+55 -1
@@ -28,7 +28,7 @@ 

  import mock

  

  # 'internal' imports

- from resultsdb_conventions.fedora import FedoraImageResult

+ from resultsdb_conventions.fedora import (FedoraImageResult, FedoraBodhiResult)

  

  # fedfind metadata dict used to avoid a round trip to get the real one.

  METADATA01 = {
@@ -157,4 +157,58 @@ 

              }

          ]

  

+     def test_fedorabodhi(self):

+         """Check the expected properties of a FedoraBodhiResult."""

+         res = FedoraBodhiResult(

+             update='FEDORA-2017-e6d7184200',

+             outcome='PASSED',

+             tc_name='update.some.test',

+             note='note here',

+             ref_url='https://www.job.link/',

+             tc_url='https://www.test.case/',

+             source='testsource'

+         )

+         # Report to a MagicMock, so we can check create_result args

+         fakeapi = mock.MagicMock()

+         res.report(fakeapi)

+ 

+         # basic attribute checks

+         assert res.outcome == 'PASSED'

+         assert res.tc_name == 'update.some.test'

+         assert res.note == 'note here'

+         assert res.ref_url == 'https://www.job.link/'

+         assert res.tc_url == 'https://www.test.case/'

+         assert res.source == 'testsource'

+ 

+         # check the testcase object

+         assert res.testcase_object == {

+             'name': 'update.some.test',

+             'ref_url': 'https://www.test.case/',

+         }

+ 

+         # check the extradata

+         assert res.extradata == {

+             'item': 'FEDORA-2017-e6d7184200',

+             'meta.conventions': 'result fedora.bodhi',

+             'source': 'testsource',

+             'type': 'bodhi_update'

+         }

+ 

+         # check the groups

+         assert res.groups == [

+             {

+                 'description': 'source.testsource',

+                 'uuid': 'ddf8c194-5e34-50ec-b0e8-205c63b0dfc1'

+             },

+             {

+                 'description': 'bodhi.FEDORA-2017-e6d7184200',

+                 'ref_url': 'https://bodhi.fedoraproject.org/updates/FEDORA-2017-e6d7184200',

+                 'uuid': 'c67605d5-0ff7-5f1e-91df-3d2ad094c902'

+             },

+             {

+                 'description': 'testsource.FEDORA-2017-e6d7184200',

+                 'uuid': 'd02731e7-46d3-545b-b355-3ff01ff62de1'

+             },

+         ]

+ 

  # vim: set textwidth=120 ts=8 et sw=4:

This adds a new convention, FedoraBodhiResult, for results
associated with Fedora Bodhi updates. It's pretty simple for
now; we could go query a bunch of properties of the update from
Bodhi and include them in the extradata, but not sure we need
to do that yet. I based the values on some results that are
already present in dev resultsdb, like:
http://taskotron-dev.fedoraproject.org/resultsdb/results/10516367

Pagure-CI seems to be a bit busted ATM...for the record, I ran tox locally and it passes.

Pull-Request has been merged by adamwill

7 years ago