bodhi/model.py | 3 +
bodhi/tests/test_controllers.py | 75 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 74 insertions(+), 4 deletions(-)
New commits:
commit 4c5df526eda59d1edae9b8a1ae625f7d9af9dd2d
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Jun 30 19:41:56 2010 -0400
Improve our test suite to ensure that people can disable autokarma with critpath
updates
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index bb068a1..fe5804a 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -1510,6 +1510,73 @@ class TestControllers(testutil.DBTest):
update = PackageUpdate.byTitle(params['builds'])
assert update.request == 'testing'
+ def test_critpath_with_autokarma_disabled(self):
+ """
+ Ensure that people can still disable karma automatism with critpath
+ updates.
+ """
+ releng = login(group='proventesters')
+ create_release(locked=True)
+ params = {
+ 'builds' : 'kernel-2.6.31-1.fc7',
+ 'release' : 'Fedora 7',
+ 'type_' : 'bugfix',
+ 'bugs' : '',
+ 'notes' : 'foobar',
+ 'autokarma': False,
+ 'stable_karma' : 10,
+ 'request': None,
+ 'unstable_karma' : -10,
+ }
+ self.save_update(params, releng)
+ update = PackageUpdate.byTitle(params['builds'])
+ testutil.create_request('/updates/%s' % params['builds'],
+ method='GET', headers=releng)
+
+ # Ensure releng/QA can't push critpath updates alone
+ assert "Push to Testing" in cherrypy.response.body[0]
+ assert "Push Critical Path update to Stable" not in
cherrypy.response.body[0]
+
+ # Have a developer +1 the update
+ developer = login(username='bob')
+
testutil.create_request('/updates/comment?text=foobar&title=%s&karma=1' %
+ params['builds'], method='POST',
headers=developer)
+ testutil.create_request('/updates/%s' % params['builds'],
+ method='GET', headers=developer)
+ assert "Push Critical Path update to Stable" not in
cherrypy.response.body[0]
+ update = PackageUpdate.byTitle(params['builds'])
+ assert not update.request
+ assert len(update.comments) == 1
+ assert update.comments[0].author == 'bob'
+
+ # Make sure not even releng can submit it to stable until it gets another
+ # approval
+ testutil.create_request('/updates/request/stable/%s' %
params['builds'],
+ method='GET', headers=releng)
+ update = PackageUpdate.byTitle(params['builds'])
+ assert update.request == 'testing'
+ assert update.karma == 1
+ update.request = None
+
+ # Have another developer +1 it, so it gets up to +2
+ # Ensure we can't push it to stable, until we get admin approval
+
testutil.create_request('/updates/comment?text=foobar&title=%s&karma=1' %
+ params['builds'], method='POST',
+ headers=login(username='foobar'))
+ testutil.create_request('/updates/%s' % params['builds'],
+ method='GET',
headers=login(username='foobar'))
+ assert "Push Critical Path update to Stable" not in
cherrypy.response.body[0]
+ update = PackageUpdate.byTitle(params['builds'])
+ assert update.karma == 2
+ assert update.request != 'stable', update.request
+
+ # Have releng try again, and ensure it can be pushed to stable
+
testutil.create_request('/updates/comment?text=foobar&title=%s&karma=1' %
+ params['builds'], method='POST',
headers=releng)
+ update = PackageUpdate.byTitle(params['builds'])
+ print update.stable_karma, update.unstable_karma
+ assert update.request == None
+
def test_critpath_to_pending_release_num_approved_comments(self):
"""
Ensure releng/qa can push critpath updates to stable for pending releases
@@ -1523,9 +1590,10 @@ class TestControllers(testutil.DBTest):
'type_' : 'bugfix',
'bugs' : '',
'notes' : 'foobar',
- 'stable_karma' : 1,
+ 'autokarma': True,
+ 'stable_karma' : 10,
'request': None,
- 'unstable_karma' : -1,
+ 'unstable_karma' : -10,
}
self.save_update(params, releng)
update = PackageUpdate.byTitle(params['builds'])
@@ -1573,7 +1641,8 @@ class TestControllers(testutil.DBTest):
testutil.create_request('/updates/comment?text=foobar&title=%s&karma=1' %
params['builds'], method='POST',
headers=releng)
update = PackageUpdate.byTitle(params['builds'])
- assert update.request == 'stable'
+ print update.stable_karma, update.unstable_karma
+ assert update.request == 'stable', update.request
# Reset it
update.request = None
commit 7dcecc0e4061d9715948c441a67ac8788a315ffc
Author: Luke Macken <lmacken(a)redhat.com>
Date: Wed Jun 30 19:32:26 2010 -0400
Only push approved critpath updates to stable if karma automatism is enabled
diff --git a/bodhi/model.py b/bodhi/model.py
index cd0320c..333f48b 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -766,8 +766,9 @@ class PackageUpdate(SQLObject):
# If we weren't approved before, and now are, push to stable
if not critpath_approved and self.critpath_approved:
self.comment('Critical path update approved',
author='bodhi')
- self.request = 'stable'
mail.send_admin('critpath_approved', self)
+ if self.stable_karma != 0:
+ self.request = 'stable'
# Send a notification to everyone that has commented on this update
mail.send(self.people_to_notify(), 'comment', self)