prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  bodhi-check-policies only operates on unpushed updates
  I noticed today when working on #1514 that the update query that ```bodhi-check-policies``` performs only selects [unpushed updates](https://github.com/fedora-infra/bodhi/blob/3.1.0/bodhi/server/scripts/check_policies.py#L40-L42):
  
  ```
  updates = models.Update.query.filter(models.Update.pushed == false())\
          .filter(models.Update.status.in_(
                  [models.UpdateStatus.pending, models.UpdateStatus.testing]))
  ```
  
  I think this is probably not what we want, as [testing updates are marked pushed](https://github.com/fedora-infra/bodhi/blob/3b655f2/bodhi/server/consumers/masher.py#L845-L857). This means we will only consult Greenwave about pending updates.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bodhi/server/scripts/check_policies.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # Copyright © 2017 Red Hat, Inc.
  3 #
  4 # This file is part of Bodhi.
  5 #
  6 # This program is free software; you can redistribute it and/or
  7 # modify it under the terms of the GNU General Public License
  8 # as published by the Free Software Foundation; either version 2
  9 # of the License, or (at your option) any later version.
  10 #
  11 # This program is distributed in the hope that it will be useful,
  12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 # GNU General Public License for more details.
  15 #
  16 # You should have received a copy of the GNU General Public License
  17 # along with this program; if not, write to the Free Software
  18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  19 
  20 """
  21 Check the enforced policies by Greenwave for each open update.
  22 
  23 Ideally, this should be done in a fedmsg consumer but we currently do not have any
  24 messages in the message bus yet.
  25 """
  26 import click
  27 from sqlalchemy.sql.expression import false
  28 
  29 from bodhi.server import config, initialize_db, models, Session
  30 
  31 
  32 @click.command()
  33 @click.version_option(message='%(version)s')
  34 def check():
  35     """Check the enforced policies by Greenwave for each open update."""
  36     initialize_db(config.config)
  37     session = Session()
  38 
  39     updates = models.Update.query.filter(models.Update.pushed == false())\
  40         .filter(models.Update.status.in_(
  41                 [models.UpdateStatus.pending, models.UpdateStatus.testing]))
  42     for update in updates:
  43         try:
  44             update.update_test_gating_status()
  45             session.commit()
  46         except Exception as e:
  47             # If there is a problem talking to Greenwave server, print the error.
  48             click.echo(str(e))
  49             session.rollback()
  50 
  51 
  52 if __name__ == '__main__':
  53     check()
  54
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bodhi/server/scripts/check_policies.py b/bodhi/server/scripts/check_policies.py
  --- a/bodhi/server/scripts/check_policies.py
  +++ b/bodhi/server/scripts/check_policies.py
  @@ -24,7 +24,6 @@
   messages in the message bus yet.
   """
   import click
  -from sqlalchemy.sql.expression import false
   
   from bodhi.server import config, initialize_db, models, Session
   
  @@ -36,9 +35,8 @@
       initialize_db(config.config)
       session = Session()
   
  -    updates = models.Update.query.filter(models.Update.pushed == false())\
  -        .filter(models.Update.status.in_(
  -                [models.UpdateStatus.pending, models.UpdateStatus.testing]))
  +    updates = models.Update.query.filter(models.Update.status.in_(
  +        [models.UpdateStatus.pending, models.UpdateStatus.testing]))
       for update in updates:
           try:
               update.update_test_gating_status()
  
verification_info: {"golden_diff": "diff --git a/bodhi/server/scripts/check_policies.py b/bodhi/server/scripts/check_policies.py\n--- a/bodhi/server/scripts/check_policies.py\n+++ b/bodhi/server/scripts/check_policies.py\n@@ -24,7 +24,6 @@\n messages in the message bus yet.\n \"\"\"\n import click\n-from sqlalchemy.sql.expression import false\n \n from bodhi.server import config, initialize_db, models, Session\n \n@@ -36,9 +35,8 @@\n     initialize_db(config.config)\n     session = Session()\n \n-    updates = models.Update.query.filter(models.Update.pushed == false())\\\n-        .filter(models.Update.status.in_(\n-                [models.UpdateStatus.pending, models.UpdateStatus.testing]))\n+    updates = models.Update.query.filter(models.Update.status.in_(\n+        [models.UpdateStatus.pending, models.UpdateStatus.testing]))\n     for update in updates:\n         try:\n             update.update_test_gating_status()\n", "issue": "bodhi-check-policies only operates on unpushed updates\nI noticed today when working on #1514 that the update query that ```bodhi-check-policies``` performs only selects [unpushed updates](https://github.com/fedora-infra/bodhi/blob/3.1.0/bodhi/server/scripts/check_policies.py#L40-L42):\r\n\r\n```\r\nupdates = models.Update.query.filter(models.Update.pushed == false())\\\r\n        .filter(models.Update.status.in_(\r\n                [models.UpdateStatus.pending, models.UpdateStatus.testing]))\r\n```\r\n\r\nI think this is probably not what we want, as [testing updates are marked pushed](https://github.com/fedora-infra/bodhi/blob/3b655f2/bodhi/server/consumers/masher.py#L845-L857). This means we will only consult Greenwave about pending updates.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright \u00a9 2017 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\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\n\"\"\"\nCheck the enforced policies by Greenwave for each open update.\n\nIdeally, this should be done in a fedmsg consumer but we currently do not have any\nmessages in the message bus yet.\n\"\"\"\nimport click\nfrom sqlalchemy.sql.expression import false\n\nfrom bodhi.server import config, initialize_db, models, Session\n\n\n@click.command()\n@click.version_option(message='%(version)s')\ndef check():\n    \"\"\"Check the enforced policies by Greenwave for each open update.\"\"\"\n    initialize_db(config.config)\n    session = Session()\n\n    updates = models.Update.query.filter(models.Update.pushed == false())\\\n        .filter(models.Update.status.in_(\n                [models.UpdateStatus.pending, models.UpdateStatus.testing]))\n    for update in updates:\n        try:\n            update.update_test_gating_status()\n            session.commit()\n        except Exception as e:\n            # If there is a problem talking to Greenwave server, print the error.\n            click.echo(str(e))\n            session.rollback()\n\n\nif __name__ == '__main__':\n    check()\n", "path": "bodhi/server/scripts/check_policies.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright \u00a9 2017 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\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\n\"\"\"\nCheck the enforced policies by Greenwave for each open update.\n\nIdeally, this should be done in a fedmsg consumer but we currently do not have any\nmessages in the message bus yet.\n\"\"\"\nimport click\n\nfrom bodhi.server import config, initialize_db, models, Session\n\n\n@click.command()\n@click.version_option(message='%(version)s')\ndef check():\n    \"\"\"Check the enforced policies by Greenwave for each open update.\"\"\"\n    initialize_db(config.config)\n    session = Session()\n\n    updates = models.Update.query.filter(models.Update.status.in_(\n        [models.UpdateStatus.pending, models.UpdateStatus.testing]))\n    for update in updates:\n        try:\n            update.update_test_gating_status()\n            session.commit()\n        except Exception as e:\n            # If there is a problem talking to Greenwave server, print the error.\n            click.echo(str(e))\n            session.rollback()\n\n\nif __name__ == '__main__':\n    check()\n", "path": "bodhi/server/scripts/check_policies.py"}]}