bodhi/controllers.py | 18 ++++++++++++++++--
bodhi/tests/test_controllers.py | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)
New commits:
commit 025bce0cbdfec024ef96e2665d80d6ce74ef9be6
Author: Luke Macken <lmacken(a)redhat.com>
Date: Tue Nov 16 15:18:40 2010 -0500
Support querying and commenting on updates by the update ID.
This is to help make it easy for AutoQA to integrate with Bodhi.
diff --git a/bodhi/controllers.py b/bodhi/controllers.py
index 88bde43..f323291 100644
--- a/bodhi/controllers.py
+++ b/bodhi/controllers.py
@@ -315,7 +315,14 @@ class Root(controllers.RootController):
# The package argument may be an update, build or package.
if package:
try:
- update = PackageUpdate.byTitle(package)
+ try:
+ update = PackageUpdate.byTitle(package)
+ except:
+ update = PackageUpdate.select(PackageUpdate.q.updateid==package)
+ if update.count():
+ update = update[0]
+ else:
+ raise SQLObjectNotFound
if not release and not status and not type_:
updates = [update]
else:
@@ -1239,7 +1246,14 @@ class Root(controllers.RootController):
flash_log("Karma must be one of (1, 0, -1), not %s" % repr(karma))
else:
try:
- update = PackageUpdate.byTitle(title)
+ try:
+ update = PackageUpdate.byTitle(title)
+ except SQLObjectNotFound:
+ update = PackageUpdate.select(PackageUpdate.q.updateid == title)
+ if update.count():
+ update = update[0]
+ else:
+ raise SQLObjectNotFound
if text == 'None':
text = None
else:
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index f4fbc43..9111c95 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -972,6 +972,15 @@ class TestControllers(testutil.DBTest):
}
self.save_update(params, session)
+ # Test querying by updateid
+ up = PackageUpdate.byTitle(params['builds'])
+ up.assign_id()
+ url = '/updates/list?' + urllib.urlencode({
+ 'package' : up.updateid
+ })
+ testutil.create_request(url, method='GET')
+ assert "1 update found" in cherrypy.response.body[0]
+
def test_default_request(self):
"""
Verify that updates are automatically submitted to testing, and that
@@ -2719,3 +2728,29 @@ class TestControllers(testutil.DBTest):
log = testutil.get_log()
update = PackageUpdate.byTitle(params['builds'])
assert update.request == 'stable', log
+
+ def test_comment_by_updateid(self):
+ """ Ensure we can comment on updates using the updateid
"""
+ session = login()
+ create_release()
+ params = {
+ 'builds' : 'TurboGears-1.0.8-1.fc7',
+ 'type_' : 'bugfix',
+ 'bugs' : '',
+ 'notes' : 'foobar',
+ 'request' : 'Stable',
+ 'suggest_reboot' : True,
+ 'autokarma' : True,
+ 'stable_karma' : 5,
+ 'unstable_karma' : -5
+ }
+ testutil.capture_log(['bodhi.controller', 'bodhi.util'])
+ self.save_update(params, session)
+ log = testutil.get_log()
+ up = PackageUpdate.byTitle(params['builds'])
+ up.assign_id()
+ assert up.updateid
+ testutil.create_request('/updates/comment/foobar/%s' % up.updateid,
+ method='POST', headers=session)
+ update = PackageUpdate.byTitle(params['builds'])
+ assert update.comments[-1].text == 'foobar', update.comments
Show replies by date