bodhi.egg-info/PKG-INFO | 2 - bodhi/model.py | 11 ++++++++ bodhi/tests/test_controllers.py | 52 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-)
New commits: commit dd36e4d8fada89bfae5ba66d865b1d2575eb8d59 Author: Luke Macken lmacken@redhat.com Date: Tue Nov 22 23:07:28 2011 -0500
Disallow pushing critpath to stable after 2 weeks in testing if there is negative karma
diff --git a/bodhi.egg-info/PKG-INFO b/bodhi.egg-info/PKG-INFO index 2c063a8..bb2ae46 100644 --- a/bodhi.egg-info/PKG-INFO +++ b/bodhi.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: bodhi -Version: 0.8.4 +Version: 0.8.5 Summary: Bodhi is a modular web-system that facilitates the process of publishing updates for a Fedora-based software distribution Home-page: https://fedorahosted.org/bodhi Author: Luke Macken diff --git a/bodhi/model.py b/bodhi/model.py index 2b1c805..e213b7d 100644 --- a/bodhi/model.py +++ b/bodhi/model.py @@ -24,6 +24,7 @@ from kid import XML from kid.element import encode_entity from sqlobject import * from datetime import datetime +from collections import defaultdict
from turbogears import config from turbogears.database import PackageHub @@ -1181,6 +1182,16 @@ class PackageUpdate(SQLObject): simply return True. """ if self.critpath: + # Ensure there is no negative karma. We're looking at the sum of + # each users karma for this update, which takes into account + # changed votes. + feedback = defaultdict(int) + for comment in self.comments: + if not comment.anonymous: + feedback[comment.author] += comment.karma + for karma in feedback.values(): + if karma < 0: + return False num_days = config.get('critpath.stable_after_days_without_negative_karma') return self.days_in_testing >= num_days num_days = self.release.mandatory_days_in_testing diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py index 82df22e..0762163 100644 --- a/bodhi/tests/test_controllers.py +++ b/bodhi/tests/test_controllers.py @@ -2148,6 +2148,7 @@ class TestControllers(testutil.DBTest): # Ensure it can now be pushed testutil.create_request('/updates/%s' % params['builds'], method='GET', headers=releng) + assert "Mark Critical Path update as Stable" in cherrypy.response.body[0]
testutil.create_request('/updates/request/stable/%s' % params['builds'], method='POST', @@ -2155,6 +2156,57 @@ class TestControllers(testutil.DBTest): update = PackageUpdate.byTitle(params['builds']) assert update.request == 'stable', update.request
+ def test_critpath_two_weeks_with_negative_karma(self): + """ + Ensure critpath updates cannot be pushed to stable after two weeks with + negative feedback. + """ + 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': True, + 'stable_karma' : 3, + 'request': None, + 'unstable_karma' : -3, + 'autokarma': True, + } + 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] + testutil.create_request('/updates/request/stable/%s' % + params['builds'], method='POST', + headers=releng) + update = PackageUpdate.byTitle(params['builds']) + assert update.request == 'testing', update.request + + # Time travel + update.pushed = True + update.request = None + update.status = 'testing' + update.status_comment() + update.comments[-1].timestamp -= timedelta(days=14) + + # Give some negative karma + testutil.create_request('/updates/comment?text=foobar&title=%s&karma=-1' % + params['builds'], method='POST', headers=releng) + + # Ensure it cannot now be pushed + testutil.create_request('/updates/request/stable/%s' % + params['builds'], method='POST', + headers=releng) + update = PackageUpdate.byTitle(params['builds']) + assert update.request != 'stable', update.request + def test_created_since(self): session = login() create_release()