Repository: fedora-infra/bodhi

Issue:
The CLI seems to have lost the ability to query overrides by attributes other than user
It used to be possible to query overrides by package name, and possibly other attributes. The current CLI only allows querying by user:

```
$ bodhi overrides query --help                                  
Usage: bodhi overrides query [OPTIONS]                     

  Query the buildroot overrides.                           

Options:                                                   
  --user TEXT  Updates submitted by a specific user        
  --staging    Use the staging bodhi instance              
  --url TEXT   URL of a Bodhi server. Ignored if --staging is set. Can be set                                          
               with BODHI_URL environment variable         
  --help       Show this message and exit.
```

I'm going to mark this as high priority since it is a regression.


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
@@ -499,13 +499,20 @@ def overrides():
 
 @overrides.command('query')
 @click.option('--user', default=None,
-              help='Updates submitted by a specific user')
+              help='Overrides submitted by a specific user')
 @click.option('--staging', help='Use the staging bodhi instance',
               is_flag=True, default=False)
 @click.option('--mine', is_flag=True,
               help='Show only your overrides.')
+@click.option('--packages', default=None,
+              help='Query by comma-separated package name(s)')
+@click.option('--expired/--active', default=None,
+              help='show only expired or active overrides')
+@click.option('--releases', default=None,
+              help='Query by release shortname(s). e.g. F26')
 @url_option
-def query_buildroot_overrides(url, user=None, mine=False, **kwargs):
+def query_buildroot_overrides(url, user=None, mine=False, packages=None,
+                              expired=None, releases=None, **kwargs):
     # Docs that show in the --help
     """
     Query the buildroot overrides.
@@ -521,6 +528,9 @@ def query_buildroot_overrides(url, user=None, mine=False, **kwargs):
         mine (bool): Whether to use the --mine flag was given.
         url (unicode): The URL of a Bodhi server to create the update on. Ignored if staging is
                        True.
+        packages (unicode): If supplied, the overrides for these package are queried
+        expired (bool): If supplied, True returns only expired overrides, False only active.
+        releases (unicode): If supplied, the overrides for these releases are queried.
         kwargs (dict): Other keyword arguments passed to us by click.
     """
     client = bindings.BodhiClient(base_url=url, staging=kwargs['staging'])
@@ -530,7 +540,7 @@ def query_buildroot_overrides(url, user=None, mine=False, **kwargs):
         else:
             client.init_username()
             user = client.username
-    resp = client.list_overrides(user=user)
+    resp = client.list_overrides(user=user, packages=packages, expired=expired, releases=releases)
     print_resp(resp, client)
 
 
diff --git a/bodhi/client/bindings.py b/bodhi/client/bindings.py
--- a/bodhi/client/bindings.py
+++ b/bodhi/client/bindings.py
@@ -322,15 +322,24 @@ def save_override(self, nvr, duration, notes, edit=False, expired=False):
             'overrides/', verb='POST', auth=True, data=data)
 
     @errorhandled
-    def list_overrides(self, user=None):
+    def list_overrides(self, user=None, packages=None, expired=None, releases=None):
         """ List buildroot overrides.
 
         :kwarg user: A username whose buildroot overrides you want returned.
+        :kwarg package: package name to filter buildroot overrides by.
+        :kwarg expired: True to return only expired overrides, False for only Active.
+        :kwarg releases: release shortnames to filter buildroot overrides by.
 
         """
         params = {}
         if user:
             params['user'] = user
+        if packages:
+            params['packages'] = packages
+        if expired is not None:
+            params['expired'] = expired
+        if releases:
+            params['releases'] = releases
         return self.send_request('overrides/', verb='GET', params=params)
 
     def init_username(self):


Test patch:
diff --git a/bodhi/tests/client/test_bindings.py b/bodhi/tests/client/test_bindings.py
--- a/bodhi/tests/client/test_bindings.py
+++ b/bodhi/tests/client/test_bindings.py
@@ -387,9 +387,9 @@ def test_with_user(self):
         client.send_request.assert_called_once_with('overrides/', verb='GET',
                                                     params={'user': 'bowlofeggs'})
 
-    def test_without_user(self):
+    def test_without_parameters(self):
         """
-        Test without the user parameter.
+        Test without the parameters.
         """
         client = bindings.BodhiClient()
         client.send_request = mock.MagicMock(return_value='response')
@@ -399,6 +399,58 @@ def test_without_user(self):
         self.assertEqual(response, 'response')
         client.send_request.assert_called_once_with('overrides/', verb='GET', params={})
 
+    def test_with_package(self):
+        """
+        Test with the package parameter.
+        """
+        client = bindings.BodhiClient()
+        client.send_request = mock.MagicMock(return_value='response')
+
+        response = client.list_overrides(packages='bodhi')
+
+        self.assertEqual(response, 'response')
+        client.send_request.assert_called_once_with('overrides/', verb='GET',
+                                                    params={'packages': 'bodhi'})
+
+    def test_with_expired(self):
+        """
+        Test --expired with the expired/active click boolean parameter.
+        """
+        client = bindings.BodhiClient()
+        client.send_request = mock.MagicMock(return_value='response')
+
+        response = client.list_overrides(expired=True)
+
+        self.assertEqual(response, 'response')
+        client.send_request.assert_called_once_with('overrides/', verb='GET',
+                                                    params={'expired': True})
+
+    def test_with_active(self):
+        """
+        Test --active with the expired/active click boolean parameter.
+        """
+        client = bindings.BodhiClient()
+        client.send_request = mock.MagicMock(return_value='response')
+
+        response = client.list_overrides(expired=False)
+
+        self.assertEqual(response, 'response')
+        client.send_request.assert_called_once_with('overrides/', verb='GET',
+                                                    params={'expired': False})
+
+    def test_with_releases(self):
+        """
+        Test with the releases parameter.
+        """
+        client = bindings.BodhiClient()
+        client.send_request = mock.MagicMock(return_value='response')
+
+        response = client.list_overrides(releases='F24')
+
+        self.assertEqual(response, 'response')
+        client.send_request.assert_called_once_with('overrides/', verb='GET',
+                                                    params={'releases': 'F24'})
+
 
 class TestBodhiClient_override_str(unittest.TestCase):
     """