-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script and tests for moving a batched request to a stable request
- Loading branch information
1 parent
2497fa6
commit 44e5d19
Showing
10 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
"""This script is responsible for moving all updates with a batched request to a stable request.""" | ||
|
||
import sys | ||
import click | ||
|
||
from bodhi.server import config, models, Session, initialize_db | ||
|
||
|
||
@click.command() | ||
@click.version_option(message='%(version)s') | ||
def dequeue_stable(): | ||
"""Convert all batched requests to stable requests.""" | ||
initialize_db(config.config) | ||
db = Session() | ||
|
||
try: | ||
batched = db.query(models.Update).filter_by(request=models.UpdateRequest.batched).all() | ||
|
||
for update in batched: | ||
update.request = models.UpdateRequest.stable | ||
db.commit() | ||
|
||
except Exception as e: | ||
print(str(e)) | ||
db.rollback() | ||
Session.remove() | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This program is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU General Public License | ||
# as published by the Free Software Foundation; either version 2 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
""" | ||
This module contains tests for the bodhi.server.scripts.dequeue_stable module. | ||
""" | ||
from click import testing | ||
|
||
from bodhi.server import models | ||
from bodhi.server.scripts import dequeue_stable | ||
from bodhi.tests.server.base import BaseTestCase | ||
|
||
|
||
class TestDequeueStable(BaseTestCase): | ||
""" | ||
This class contains tests for the dequeue_stable() function. | ||
""" | ||
def test_dequeue_stable(self): | ||
""" | ||
Assert that dequeue_stable moves only the batched updates to stable. | ||
""" | ||
runner = testing.CliRunner() | ||
|
||
update = self.db.query(models.Update).all()[0] | ||
update.request = models.UpdateRequest.batched | ||
update.status = models.UpdateStatus.testing | ||
self.db.commit() | ||
|
||
result = runner.invoke(dequeue_stable.dequeue_stable, []) | ||
self.assertEqual(result.exit_code, 0) | ||
self.assertEqual(update.request, models.UpdateRequest.stable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters