#335 Remove unused methods from ErrataAdvisoryRPMSignedHandler.
Merged 3 months ago by jkaluza. Opened 3 months ago by jkaluza.
jkaluza/freshmaker errata-refactor  into  master

@@ -24,16 +24,11 @@ 

  

  import json

  import koji

- import requests

  

- from six.moves import cStringIO

- from six.moves import configparser

- 

- from freshmaker import conf, db, log

+ from freshmaker import conf, db

  from freshmaker.events import ErrataAdvisoryRPMsSignedEvent

  from freshmaker.events import ManualRebuildWithAdvisoryEvent

  from freshmaker.handlers import ContainerBuildHandler, fail_event_on_handler_exception

- from freshmaker.kojiservice import koji_service

  from freshmaker.lightblue import LightBlue

  from freshmaker.pulp import Pulp

  from freshmaker.errata import Errata

@@ -127,32 +122,6 @@ 

  

          return []

  

-     def _get_base_image_build_target(self, image):

-         dockerfile = image.dockerfile

-         image_build_conf_url = dockerfile['content_url'].replace(

-             dockerfile['filename'], 'image-build.conf')

-         response = requests.get(image_build_conf_url)

-         try:

-             response.raise_for_status()

-         except requests.exceptions.HTTPError as e:

-             log.error(

-                 'Cannot get image-build.conf from %s.', image_build_conf_url)

-             log.exception('Server response: %s', e)

-             return None

-         config_buf = cStringIO(response.content)

-         config = configparser.RawConfigParser()

-         try:

-             config.readfp(config_buf)

-         except configparser.MissingSectionHeaderError:

-             return None

-         finally:

-             config_buf.close()

-         try:

-             return config.get('image-build', 'target')

-         except (configparser.NoOptionError, configparser.NoSectionError):

-             log.exception('image-build.conf does not have option target.')

-             return None

- 

      def _check_images_to_rebuild(self, db_event, builds):

          """

          Checks the images to rebuild and logs them using self.log_info(...).

@@ -417,14 +386,3 @@ 

              published=published, release_category=release_category,

              leaf_container_images=leaf_container_images)

          return batches

- 

-     def _find_build_srpm_name(self, build_nvr):

-         """Find srpm name from a build"""

-         with koji_service(

-                 conf.koji_profile, log, dry_run=self.dry_run) as session:

-             rpm_infos = session.get_build_rpms(build_nvr, arches='src')

-             if not rpm_infos:

-                 raise ValueError(

-                     'Build {} does not have a SRPM, although this should not '

-                     'happen in practice.'.format(build_nvr))

-             return rpm_infos[0]['name']

@@ -392,9 +392,6 @@ 

          self.patcher = helpers.Patcher(

              "freshmaker.handlers.errata.ErrataAdvisoryRPMsSignedHandler.")

  

-         self.find_build_srpm_name = self.patcher.patch(

-             '_find_build_srpm_name', return_value="httpd")

- 

          self.get_content_set_by_repo_ids = self.patcher.patch(

              'freshmaker.pulp.Pulp.get_content_set_by_repo_ids',

              return_value=["content-set-1"])

@@ -22,7 +22,6 @@ 

  # Written by Chenxiong Qi <cqi@redhat.com>

  

  import json

- import six

  

  from mock import patch, PropertyMock, Mock, call

  

@@ -39,34 +38,6 @@ 

  from tests import helpers

  

  

- class TestFindBuildSrpmName(helpers.FreshmakerTestCase):

-     """Test ErrataAdvisoryRPMsSignedHandler._find_build_srpm_name"""

- 

-     @helpers.mock_koji

-     def test_find_srpm_name(self, mocked_koji):

-         mocked_koji.add_build("bind-dyndb-ldap-2.3-8.el6")

-         mocked_koji.add_build_rpms("bind-dyndb-ldap-2.3-8.el6")

- 

-         handler = ErrataAdvisoryRPMsSignedHandler()

-         srpm_name = handler._find_build_srpm_name('bind-dyndb-ldap-2.3-8.el6')

-         self.assertEqual('bind-dyndb-ldap', srpm_name)

- 

-     @helpers.mock_koji

-     def test_error_if_no_srpm_in_build(self, mocked_koji):

-         mocked_koji.add_build("bind-dyndb-ldap-2.3-8.el6")

-         mocked_koji.add_build_rpms("bind-dyndb-ldap-2.3-8.el6", arches=["i686"])

- 

-         handler = ErrataAdvisoryRPMsSignedHandler()

- 

-         six.assertRaisesRegex(

-             self,

-             ValueError,

-             'Build bind-dyndb-ldap-2.3-8.el6 does not have a SRPM',

-             handler._find_build_srpm_name,

-             'bind-dyndb-ldap-2.3-8.el6',

-         )

- 

- 

  class TestAllowBuild(helpers.ModelsTestCase):

      """Test ErrataAdvisoryRPMsSignedHandler.allow_build"""