bodhi/controllers.py | 13 +++++++- bodhi/tests/test_controllers.py | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-)
New commits: commit 261aa87a8c090afd8a4543c46d173371f0dc439e Author: Luke Macken lmacken@redhat.com Date: Thu Jan 28 05:58:16 2010 -0500
Detect conflicting builds when editing updates (#385)
diff --git a/bodhi/controllers.py b/bodhi/controllers.py index af7c1de..33c7734 100644 --- a/bodhi/controllers.py +++ b/bodhi/controllers.py @@ -40,7 +40,7 @@ from bodhi.rss import Feed from bodhi.new import NewUpdateController, update_form from bodhi.util import make_update_link, make_type_icon, make_karma_icon, link from bodhi.util import flash_log, get_pkg_pushers, make_request_icon -from bodhi.util import json_redirect, url +from bodhi.util import json_redirect, url, get_nvr from bodhi.admin import AdminController from bodhi.metrics import MetricsController from bodhi.model import (Package, PackageBuild, PackageUpdate, Release, @@ -637,6 +637,17 @@ class Root(controllers.RootController): "engineering at %s about unpushing this update." % config.get('release_team_address')) raise InvalidUpdateException(params) + + # Check for conflicting builds when editing + for build in builds: + for other_build in builds: + if get_nvr(build)[0] == get_nvr(other_build)[0]: + if build != other_build: + flash_log("Unable to save update with conflicting builds of " + "the same package: %s and %s. Please remove one " + "and try again." % (build, other_build)) + raise InvalidUpdateException(params) + edited.unpush()
# Refresh the tags for these builds diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py index fbee31f..75c82a1 100644 --- a/bodhi/tests/test_controllers.py +++ b/bodhi/tests/test_controllers.py @@ -359,6 +359,70 @@ class TestControllers(testutil.DBTest): assert f7up.builds[0].nvr == f7build assert f7up.builds[0].package.name == 'TurboGears'
+ def test_add_older_build_to_update(self): + """ Try adding a newer build an update (#385) """ + session = login() + f7 = create_release() + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7', + 'type_' : 'bugfix', + 'bugs' : '', + 'cves' : '', + 'notes' : '' + } + self.save_update(params, session) + + # Add another build, for a different release + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7 TurboGears-1.0.2.2-1.fc7', + 'release' : 'Fedora 7', + 'type_' : 'bugfix', + 'bugs' : '1', + 'cves' : '', + 'notes' : '', + 'edited' : 'TurboGears-1.0.2.2-2.fc7,python-sqlobject-0.8.2-1.fc7', + } + + testutil.capture_log(['bodhi.controllers', 'bodhi.util', 'bodhi.model']) + self.save_update(params, session) + logs = testutil.get_log() + up = PackageUpdate.select()[0] + assert len(up.builds) == 2, up.builds + assert up.title == params['edited'] + assert u'Unable to save update with conflicting builds of the same package: TurboGears-1.0.2.2-2.fc7 and TurboGears-1.0.2.2-1.fc7. Please remove one and try again.' in logs + + def test_add_newer_build_to_update(self): + """ Try adding a newer build an update (#385) """ + session = login() + f7 = create_release() + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7', + 'type_' : 'bugfix', + 'bugs' : '', + 'cves' : '', + 'notes' : '' + } + self.save_update(params, session) + + # Add another build, for a different release + params = { + 'builds' : 'TurboGears-1.0.2.2-2.fc7 python-sqlobject-0.8.2-1.fc7 TurboGears-1.0.2.2-3.fc7', + 'release' : 'Fedora 7', + 'type_' : 'bugfix', + 'bugs' : '1', + 'cves' : '', + 'notes' : '', + 'edited' : 'TurboGears-1.0.2.2-2.fc7,python-sqlobject-0.8.2-1.fc7', + } + + testutil.capture_log(['bodhi.controllers', 'bodhi.util', 'bodhi.model']) + self.save_update(params, session) + logs = testutil.get_log() + up = PackageUpdate.select()[0] + assert len(up.builds) == 2, up.builds + assert up.title == params['edited'] + assert u'Unable to save update with conflicting builds of the same package: TurboGears-1.0.2.2-2.fc7 and TurboGears-1.0.2.2-3.fc7. Please remove one and try again.' in logs + def test_add_different_release_to_update(self): """ Try adding a build for a different release to an update (#251)