From e03b3699bf8dce0ac1bfd8849fa3dd33425044f2 Mon Sep 17 00:00:00 2001
From: Jan Kaluza <jkaluza@redhat.com>
Date: Jan 08 2019 13:01:32 +0000
Subject: Remove unused methods from ErrataAdvisoryRPMSignedHandler.


---

diff --git a/freshmaker/handlers/errata/errata_advisory_rpms_signed.py b/freshmaker/handlers/errata/errata_advisory_rpms_signed.py
index 2d827ff..91abf47 100644
--- a/freshmaker/handlers/errata/errata_advisory_rpms_signed.py
+++ b/freshmaker/handlers/errata/errata_advisory_rpms_signed.py
@@ -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 @@ class ErrataAdvisoryRPMsSignedHandler(ContainerBuildHandler):
 
         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 @@ class ErrataAdvisoryRPMsSignedHandler(ContainerBuildHandler):
             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']
diff --git a/tests/test_errata_advisory_rpms_signed_handler.py b/tests/test_errata_advisory_rpms_signed_handler.py
index 6d64d36..b176c84 100644
--- a/tests/test_errata_advisory_rpms_signed_handler.py
+++ b/tests/test_errata_advisory_rpms_signed_handler.py
@@ -392,9 +392,6 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase):
         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"])
diff --git a/tests/test_errata_advisory_state_changed.py b/tests/test_errata_advisory_state_changed.py
index 88cfe8c..4d0b44b 100644
--- a/tests/test_errata_advisory_state_changed.py
+++ b/tests/test_errata_advisory_state_changed.py
@@ -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 freshmaker.types import ArtifactBuildState, ArtifactType, EventState
 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"""
 

