Repository: fedora-infra/bodhi

Issue:
It should be possible to set required tests with the cli
When creating or editing an update with the web interface, it is possible to set required tests. For example, you can type ```dist.depcheck``` and Bodhi will make sure that taskotron test passed for the update. The CLI doesn't provide a way to specify this, we should add it.


Discussion:

Resolving patch:
diff --git a/bodhi/client/__init__.py b/bodhi/client/__init__.py
--- a/bodhi/client/__init__.py
+++ b/bodhi/client/__init__.py
@@ -56,13 +56,15 @@ def _warn_if_url_and_staging_set(ctx, param, value):
                  type=click.Choice(['security', 'bugfix', 'enhancement', 'newpackage'])),
     click.option('--notes', help='Update description'),
     click.option('--notes-file', help='Update description from a file'),
-    click.option('--bugs', help='Comma-seperated list of bug numbers', default=''),
+    click.option('--bugs', help='Comma-separated list of bug numbers', default=''),
     click.option('--close-bugs', default=True, is_flag=True, help='Automatically close bugs'),
     click.option('--request', help='Requested repository',
                  type=click.Choice(['testing', 'stable', 'unpush'])),
     click.option('--autokarma', is_flag=True, help='Enable karma automatism'),
     click.option('--stable-karma', type=click.INT, help='Stable karma threshold'),
     click.option('--unstable-karma', type=click.INT, help='Unstable karma threshold'),
+    click.option('--requirements',
+                 help='Space or comma-separated list of required Taskotron tasks'),
     click.option('--suggest', help='Post-update user suggestion',
                  type=click.Choice(['logout', 'reboot'])),
     click.option('--staging', help='Use the staging bodhi instance',


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
@@ -122,7 +122,7 @@ def test_url_flag(self, send_request):
             data={
                 'close_bugs': True, 'stable_karma': None, 'csrf_token': 'a_csrf_token',
                 'staging': False, 'builds': u'bodhi-2.2.4-1.el7', 'autokarma': True,
-                'suggest': None, 'notes': None, 'request': None, 'bugs': u'',
+                'suggest': None, 'notes': None, 'request': None, 'bugs': u'', 'requirements': None,
                 'unstable_karma': None, 'file': None, 'notes_file': None, 'type': 'bugfix'})
         self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')
 
@@ -391,7 +391,7 @@ def test_url_flag(self, send_request, query):
                 'close_bugs': True, 'stable_karma': None, 'csrf_token': 'a_csrf_token',
                 'staging': False, 'builds': u'nodejs-grunt-wrap-0.3.0-2.fc25', 'autokarma': False,
                 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25', 'suggest': None,
-                'notes': u'this is an edited note', 'notes_file': None,
+                'notes': u'this is an edited note', 'notes_file': None, 'requirements': None,
                 'request': None, 'bugs': u'', 'unstable_karma': None, 'type': 'bugfix'})
         self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')
 
@@ -429,7 +429,7 @@ def test_notes_file(self, send_request, query):
                     'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
                     'suggest': None, 'notes': 'This is a --notes-file note!',
                     'notes_file': 'notefile.txt', 'request': None, 'bugs': u'',
-                    'unstable_karma': None, 'type': 'bugfix'})
+                    'requirements': None, 'unstable_karma': None, 'type': 'bugfix'})
             self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')
 
     def test_notes_and_notes_file(self):
@@ -472,7 +472,7 @@ def test_update_title(self, send_request):
             data={
                 'close_bugs': True, 'stable_karma': None, 'csrf_token': 'a_csrf_token',
                 'staging': False, 'builds': u'drupal7-i18n-1.17-1.fc26', 'autokarma': False,
-                'edited': u'drupal7-i18n-1.17-1.fc26', 'suggest': None,
+                'edited': u'drupal7-i18n-1.17-1.fc26', 'suggest': None, 'requirements': None,
                 'notes': u'this is an edited note', 'notes_file': None,
                 'request': None, 'bugs': u'', 'unstable_karma': None, 'type': 'bugfix'})
 
@@ -512,6 +512,41 @@ def test_wrong_update_id_argument(self):
 
         self.assertEqual(result.output, expected)
 
+    @mock.patch('bodhi.client.bindings.BodhiClient.csrf',
+                mock.MagicMock(return_value='a_csrf_token'))
+    @mock.patch('bodhi.client.bindings.BodhiClient.query',
+                return_value=client_test_data.EXAMPLE_QUERY_MUNCH, autospec=True)
+    @mock.patch('bodhi.client.bindings.BodhiClient.send_request',
+                return_value=client_test_data.EXAMPLE_UPDATE_MUNCH, autospec=True)
+    def test_required_tasks(self, send_request, query):
+        """
+        Assert that valid required Taskotron Tasks are properly handled in a successful updates
+        edit request.
+        """
+        runner = testing.CliRunner()
+
+        result = runner.invoke(
+            client.edit, ['FEDORA-2017-cc8582d738', '--user', 'bowlofeggs',
+                          '--password', 's3kr3t', '--notes', 'testing required tasks',
+                          '--requirements', 'dist.depcheck dist.rpmdeplint', '--url',
+                          'http://localhost:6543'])
+
+        self.assertEqual(result.exit_code, 0)
+        bindings_client = query.mock_calls[0][1][0]
+        query.assert_called_with(
+            bindings_client, updateid=u'FEDORA-2017-cc8582d738')
+        bindings_client = send_request.mock_calls[0][1][0]
+        send_request.assert_called_with(
+            bindings_client, 'updates/', auth=True, verb='POST',
+            data={
+                'close_bugs': True, 'stable_karma': None, 'csrf_token': 'a_csrf_token',
+                'staging': False, 'builds': u'nodejs-grunt-wrap-0.3.0-2.fc25',
+                'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
+                'suggest': None, 'notes': u'testing required tasks', 'notes_file': None,
+                'requirements': u'dist.depcheck dist.rpmdeplint', 'request': None,
+                'bugs': u'', 'unstable_karma': None, 'type': 'bugfix'})
+        self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')
+
 
 class TestEditBuilrootOverrides(unittest.TestCase):
     """