Repository: fedora-infra/bodhi

Issue:
manage_releases.py needs to be able to set pending-signing-tag
Now that we have autosigning in place, we need to add ```--pending-signing-tag``` flags to ```manage_releases.py```.


Discussion:
This one should be done after #2424 is merged, so that it can be done in the new ```bodhi releases``` subcommand instead of in the soon-to-be-deprecated ```bodhi-manage-releases``` CLI.

Resolving patch:
diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -126,6 +126,8 @@ def _warn_if_url_and_staging_set(ctx, param, value):
                  help='Koji pending tag (eg: f20-updates-pending)'),
     click.option('--pending-testing-tag',
                  help='Koji pending testing tag (eg: f20-updates-testing-testing)'),
+    click.option('--pending-signing-tag',
+                 help='Koji pending signing tag (eg: f20-updates-pending-signing)'),
     click.option('--override-tag', help='Koji override tag (eg: f20-override)'),
     click.option('--state', type=click.Choice(['disabled', 'pending', 'current',
                                                'archived']),
diff --git a/bodhi/server/consumers/masher.py b/bodhi/server/consumers/masher.py
--- a/bodhi/server/consumers/masher.py
+++ b/bodhi/server/consumers/masher.py
@@ -649,6 +649,8 @@ def remove_pending_tags(self):
                 update.remove_tag(update.release.pending_stable_tag,
                                   koji=koji)
             elif update.request is UpdateRequest.testing:
+                update.remove_tag(update.release.pending_signing_tag,
+                                  koji=koji)
                 update.remove_tag(update.release.pending_testing_tag,
                                   koji=koji)
         result = koji.multiCall()


Test patch:
diff --git a/bodhi/tests/client/test___init__.py b/bodhi/tests/client/test___init__.py
--- a/bodhi/tests/client/test___init__.py
+++ b/bodhi/tests/client/test___init__.py
@@ -1446,7 +1446,8 @@ def test_url_flag(self, send_request):
             data={'dist_tag': None, 'csrf_token': 'a_csrf_token', 'staging': False, 'name': u'F27',
                   'testing_tag': None, 'pending_stable_tag': None, 'long_name': None, 'state': None,
                   'version': None, 'override_tag': None, 'branch': None, 'id_prefix': None,
-                  'pending_testing_tag': None, 'stable_tag': None, 'candidate_tag': None})
+                  'pending_testing_tag': None, 'pending_signing_tag': None, 'stable_tag': None,
+                  'candidate_tag': None})
         self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')
 
     @mock.patch('bodhi.client.bindings.BodhiClient.csrf',
diff --git a/bodhi/tests/server/consumers/test_masher.py b/bodhi/tests/server/consumers/test_masher.py
--- a/bodhi/tests/server/consumers/test_masher.py
+++ b/bodhi/tests/server/consumers/test_masher.py
@@ -447,6 +447,7 @@ def test_tags(self, publish, *args):
             release = session.query(Update).one().release
             build = session.query(Build).one()
             nvr = build.nvr
+            pending_signing_tag = release.pending_signing_tag
             pending_testing_tag = release.pending_testing_tag
             override_tag = release.override_tag
             self.koji.__tagged__[session.query(Update).first().title] = [release.override_tag,
@@ -473,8 +474,9 @@ def test_tags(self, publish, *args):
                           (u'f17-updates-candidate', u'f17-updates-testing', u'bodhi-2.0-1.fc17'))
 
         # The override tag won't get removed until it goes to stable
-        self.assertEquals(self.koji.__untag__[0], (pending_testing_tag, nvr))
-        self.assertEquals(len(self.koji.__untag__), 1)
+        self.assertEquals(self.koji.__untag__[0], (pending_signing_tag, nvr))
+        self.assertEquals(self.koji.__untag__[1], (pending_testing_tag, nvr))
+        self.assertEquals(len(self.koji.__untag__), 2)
 
         with self.db_factory() as session:
             # Set the update request to stable and the release to pending
@@ -2414,6 +2416,26 @@ def test_with_failed_tasks(self, wait_for_tasks):
         self.assert_sems(0)
 
 
+class TestComposerThread_remove_pending_tags(ComposerThreadBaseTestCase):
+    """This test class contains tests for the ComposerThread.remove_pending_tags() method."""
+    @mock.patch('bodhi.server.models.Update.remove_tag')
+    def test_with_request_testing(self, remove_tag):
+        """
+        Assert that the method calls Update.remove_tag() twice for the pending_signing_tag
+        and pending_testing_tag.
+        """
+        msg = self._make_msg()
+        t = ComposerThread(self.semmock, msg['body']['msg']['composes'][0],
+                           'bowlofeggs', log, self.Session, self.tempdir)
+        t.compose = Compose.from_dict(self.db, msg['body']['msg']['composes'][0])
+        t.log.debug = mock.MagicMock()
+
+        t.remove_pending_tags()
+
+        self.assertEqual(remove_tag.call_count, 2)
+        t.log.debug.assert_called_with("remove_pending_tags koji.multiCall result = %r", [])
+
+
 class TestComposerThread_check_all_karma_thresholds(ComposerThreadBaseTestCase):
     """Test the ComposerThread.check_all_karma_thresholds() method."""
     @mock.patch('bodhi.server.models.Update.check_karma_thresholds',