prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Side tag updates are not automatically pushed to testing 
  When I create a side tag update for a stable Fedora, it sits in pending until I manually click "push to testing". This is inconsistent with regular updates and a tad confusing.
  
  See also https://pagure.io/fedora-infrastructure/issue/8930
  
  </issue>
  <code>
  [start of bodhi/server/consumers/signed.py]
  1 # Copyright © 2016-2019 Red Hat, Inc.
  2 #
  3 # This file is part of Bodhi.
  4 #
  5 # This program is free software; you can redistribute it and/or
  6 # modify it under the terms of the GNU General Public License
  7 # as published by the Free Software Foundation; either version 2
  8 # of the License, or (at your option) any later version.
  9 #
  10 # This program is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 # GNU General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU General Public License along with
  16 # this program; if not, write to the Free Software Foundation, Inc., 51
  17 # Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18 """
  19 The "signed handler".
  20 
  21 This module is responsible for marking builds as "signed" when they get moved
  22 from the pending-signing to pending-updates-testing tag by RoboSignatory.
  23 """
  24 
  25 import logging
  26 
  27 import fedora_messaging
  28 from sqlalchemy import func
  29 
  30 from bodhi.server.config import config
  31 from bodhi.server.models import Build, UpdateStatus, TestGatingStatus
  32 from bodhi.server.util import transactional_session_maker
  33 
  34 log = logging.getLogger('bodhi')
  35 
  36 
  37 class SignedHandler(object):
  38     """
  39     The Bodhi Signed Handler.
  40 
  41     A fedora-messaging listener waiting for messages from koji about builds being tagged.
  42     """
  43 
  44     def __init__(self):
  45         """Initialize the SignedHandler."""
  46         self.db_factory = transactional_session_maker()
  47 
  48     def __call__(self, message: fedora_messaging.api.Message):
  49         """
  50         Handle messages arriving with the configured topic.
  51 
  52         This marks a build as signed if it is assigned to the pending testing release tag.
  53 
  54         Example message format::
  55             {
  56                 'body': {
  57                     'build_id': 442562,
  58                     'name': 'colord',
  59                     'tag_id': 214,
  60                     'instance': 's390',
  61                     'tag': 'f26-updates-testing-pending',
  62                     'user': 'sharkcz',
  63                     'version': '1.3.4',
  64                     'owner': 'sharkcz',
  65                     'release': '1.fc26'
  66                 },
  67             }
  68 
  69         The message can contain additional keys.
  70 
  71         Duplicate messages: this method is idempotent.
  72 
  73         Args:
  74             message: The incoming message in the format described above.
  75         """
  76         message = message.body
  77         build_nvr = '%(name)s-%(version)s-%(release)s' % message
  78         tag = message['tag']
  79 
  80         log.info("%s tagged into %s" % (build_nvr, tag))
  81 
  82         with self.db_factory() as dbsession:
  83             build = Build.get(build_nvr)
  84             if not build:
  85                 log.info("Build was not submitted, skipping")
  86                 return
  87 
  88             if not build.release:
  89                 log.info('Build is not assigned to release, skipping')
  90                 return
  91 
  92             if build.update and build.update.from_tag:
  93                 koji_testing_tag = build.release.get_testing_side_tag(build.update.from_tag)
  94                 if tag != koji_testing_tag:
  95                     log.info("Tag is not testing side tag, skipping")
  96                     return
  97             else:
  98                 if build.release.pending_testing_tag != tag:
  99                     log.info("Tag is not pending_testing tag, skipping")
  100                     return
  101 
  102             if build.signed:
  103                 log.info("Build was already marked as signed (maybe a duplicate message)")
  104                 return
  105 
  106             # This build was moved into the pending_testing tag for the applicable release, which
  107             # is done by RoboSignatory to indicate that the build has been correctly signed and
  108             # written out. Mark it as such.
  109             log.info("Build has been signed, marking")
  110             build.signed = True
  111             dbsession.flush()
  112             log.info("Build %s has been marked as signed" % build_nvr)
  113 
  114             # If every build in update is signed change status to testing
  115             if build.update \
  116                     and not build.update.release.composed_by_bodhi \
  117                     and build.update.signed:
  118                 log.info("Every build in update is signed, set status to testing")
  119 
  120                 build.update.status = UpdateStatus.testing
  121                 build.update.date_testing = func.current_timestamp()
  122                 build.update.request = None
  123                 build.update.pushed = True
  124 
  125                 if config.get("test_gating.required"):
  126                     log.debug('Test gating is required, marking the update as waiting on test '
  127                               'gating and updating it from Greenwave to get the real status.')
  128                     build.update.test_gating_status = TestGatingStatus.waiting
  129                     build.update.update_test_gating_status()
  130 
  131                 log.info(f"Update {build.update.display_name} status has been set to testing")
  132
  [end of bodhi/server/consumers/signed.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/bodhi/server/consumers/signed.py b/bodhi/server/consumers/signed.py
  --- a/bodhi/server/consumers/signed.py
  +++ b/bodhi/server/consumers/signed.py
  @@ -89,7 +89,9 @@
                   log.info('Build is not assigned to release, skipping')
                   return
   
  -            if build.update and build.update.from_tag:
  +            if build.update \
  +               and build.update.from_tag \
  +               and not build.update.release.composed_by_bodhi:
                   koji_testing_tag = build.release.get_testing_side_tag(build.update.from_tag)
                   if tag != koji_testing_tag:
                       log.info("Tag is not testing side tag, skipping")
  
verification_info: {"golden_diff": "diff --git a/bodhi/server/consumers/signed.py b/bodhi/server/consumers/signed.py\n--- a/bodhi/server/consumers/signed.py\n+++ b/bodhi/server/consumers/signed.py\n@@ -89,7 +89,9 @@\n                 log.info('Build is not assigned to release, skipping')\n                 return\n \n-            if build.update and build.update.from_tag:\n+            if build.update \\\n+               and build.update.from_tag \\\n+               and not build.update.release.composed_by_bodhi:\n                 koji_testing_tag = build.release.get_testing_side_tag(build.update.from_tag)\n                 if tag != koji_testing_tag:\n                     log.info(\"Tag is not testing side tag, skipping\")\n", "issue": "Side tag updates are not automatically pushed to testing \nWhen I create a side tag update for a stable Fedora, it sits in pending until I manually click \"push to testing\". This is inconsistent with regular updates and a tad confusing.\r\n\r\nSee also https://pagure.io/fedora-infrastructure/issue/8930\n", "before_files": [{"content": "# Copyright \u00a9 2016-2019 Red Hat, Inc.\n#\n# This file is part of Bodhi.\n#\n# This program is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License\n# as published by the Free Software Foundation; either version 2\n# of the License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\"\"\"\nThe \"signed handler\".\n\nThis module is responsible for marking builds as \"signed\" when they get moved\nfrom the pending-signing to pending-updates-testing tag by RoboSignatory.\n\"\"\"\n\nimport logging\n\nimport fedora_messaging\nfrom sqlalchemy import func\n\nfrom bodhi.server.config import config\nfrom bodhi.server.models import Build, UpdateStatus, TestGatingStatus\nfrom bodhi.server.util import transactional_session_maker\n\nlog = logging.getLogger('bodhi')\n\n\nclass SignedHandler(object):\n    \"\"\"\n    The Bodhi Signed Handler.\n\n    A fedora-messaging listener waiting for messages from koji about builds being tagged.\n    \"\"\"\n\n    def __init__(self):\n        \"\"\"Initialize the SignedHandler.\"\"\"\n        self.db_factory = transactional_session_maker()\n\n    def __call__(self, message: fedora_messaging.api.Message):\n        \"\"\"\n        Handle messages arriving with the configured topic.\n\n        This marks a build as signed if it is assigned to the pending testing release tag.\n\n        Example message format::\n            {\n                'body': {\n                    'build_id': 442562,\n                    'name': 'colord',\n                    'tag_id': 214,\n                    'instance': 's390',\n                    'tag': 'f26-updates-testing-pending',\n                    'user': 'sharkcz',\n                    'version': '1.3.4',\n                    'owner': 'sharkcz',\n                    'release': '1.fc26'\n                },\n            }\n\n        The message can contain additional keys.\n\n        Duplicate messages: this method is idempotent.\n\n        Args:\n            message: The incoming message in the format described above.\n        \"\"\"\n        message = message.body\n        build_nvr = '%(name)s-%(version)s-%(release)s' % message\n        tag = message['tag']\n\n        log.info(\"%s tagged into %s\" % (build_nvr, tag))\n\n        with self.db_factory() as dbsession:\n            build = Build.get(build_nvr)\n            if not build:\n                log.info(\"Build was not submitted, skipping\")\n                return\n\n            if not build.release:\n                log.info('Build is not assigned to release, skipping')\n                return\n\n            if build.update and build.update.from_tag:\n                koji_testing_tag = build.release.get_testing_side_tag(build.update.from_tag)\n                if tag != koji_testing_tag:\n                    log.info(\"Tag is not testing side tag, skipping\")\n                    return\n            else:\n                if build.release.pending_testing_tag != tag:\n                    log.info(\"Tag is not pending_testing tag, skipping\")\n                    return\n\n            if build.signed:\n                log.info(\"Build was already marked as signed (maybe a duplicate message)\")\n                return\n\n            # This build was moved into the pending_testing tag for the applicable release, which\n            # is done by RoboSignatory to indicate that the build has been correctly signed and\n            # written out. Mark it as such.\n            log.info(\"Build has been signed, marking\")\n            build.signed = True\n            dbsession.flush()\n            log.info(\"Build %s has been marked as signed\" % build_nvr)\n\n            # If every build in update is signed change status to testing\n            if build.update \\\n                    and not build.update.release.composed_by_bodhi \\\n                    and build.update.signed:\n                log.info(\"Every build in update is signed, set status to testing\")\n\n                build.update.status = UpdateStatus.testing\n                build.update.date_testing = func.current_timestamp()\n                build.update.request = None\n                build.update.pushed = True\n\n                if config.get(\"test_gating.required\"):\n                    log.debug('Test gating is required, marking the update as waiting on test '\n                              'gating and updating it from Greenwave to get the real status.')\n                    build.update.test_gating_status = TestGatingStatus.waiting\n                    build.update.update_test_gating_status()\n\n                log.info(f\"Update {build.update.display_name} status has been set to testing\")\n", "path": "bodhi/server/consumers/signed.py"}]}