summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2008-10-30 04:31:12 (GMT)
committerLuke Macken <lmacken@redhat.com>2008-10-30 05:03:06 (GMT)
commitbcc673fab69067e555654113d640f0152511f225 (patch)
tree83d4b3d4f0741471f29fe65d0163a18aced53293
parentc3979d71692d9186427fd21095aa3ade9207dfad (diff)
downloadbodhi-bcc673fab69067e555654113d640f0152511f225.zip
bodhi-bcc673fab69067e555654113d640f0152511f225.tar.gz
bodhi-bcc673fab69067e555654113d640f0152511f225.tar.xz
Add a revoke action, and a unit test for it (myfedora#18)
-rw-r--r--bodhi/model.py13
-rw-r--r--bodhi/tests/test_controllers.py18
2 files changed, 30 insertions, 1 deletions
diff --git a/bodhi/model.py b/bodhi/model.py
index 32bd047..293d097 100644
--- a/bodhi/model.py
+++ b/bodhi/model.py
@@ -286,7 +286,7 @@ class PackageUpdate(SQLObject):
if not authorized_user(self, identity):
raise InvalidRequest("Unauthorized to perform action on %s" %
self.title)
- if action not in ('testing', 'stable', 'obsolete', 'unpush'):
+ if action not in ('testing', 'stable', 'obsolete', 'unpush', 'revoke'):
raise InvalidRequest("Unknown request: %s" % action)
if action == self.status:
raise InvalidRequest("%s already %s" % (self.title, action))
@@ -331,6 +331,17 @@ class PackageUpdate(SQLObject):
"already released, and is newer "
"than %s" % (oldBuild['nvr'],
mybuild['nvr']))
+ elif action == 'revoke':
+ if self.request:
+ flash_log('%s %s request revoked' % (self.title, self.request))
+ self.request = None
+ self.comment('%s request revoked' % action,
+ author=identity.current.user_name)
+ mail.send_admin('revoke', self)
+ else:
+ flash_log('%s does not have a request to revoke' % self.title)
+ return
+
self.request = action
self.pushed = False
self.date_pushed = None
diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py
index ea03252..efec675 100644
--- a/bodhi/tests/test_controllers.py
+++ b/bodhi/tests/test_controllers.py
@@ -1123,3 +1123,21 @@ class TestControllers(testutil.DBTest):
assert PackageUpdate.select().count() == 1
assert PackageBuild.select().count() == len(params['builds'].split(','))
testutil.print_log()
+
+ def test_revoke_request(self):
+ session = login()
+ create_release(num='8', dist='dist-f')
+ params = {
+ 'builds' : u'TurboGears-1.0.7-1.fc8',
+ 'type_' : 'bugfix',
+ 'bugs' : '',
+ 'notes' : '',
+ }
+ testutil.capture_log(['bodhi.controllers', 'bodhi.util'])
+ self.save_update(params, session)
+ update = PackageUpdate.byTitle(params['builds'])
+ assert update.request == 'testing'
+ testutil.create_request('/updates/request/revoke/%s' % params['builds'],
+ headers=session, method='POST')
+ update = PackageUpdate.byTitle(params['builds'])
+ assert update.request == None