Skip to content

Commit

Permalink
Allow to configure a release without an override tag.
Browse files Browse the repository at this point in the history
A few releases do not make use of the buildroot override
(eg container, rawhide, flatpak). This commit makes it possible
to create a release without the override tag.
If an user tries to create a buildroot override for such a release
an error message will be displayed.

Fixes fedora-infra#3447

Signed-off-by: Clement Verna <cverna@tutanota.com>
  • Loading branch information
cverna committed Aug 19, 2019
1 parent ce61a98 commit 39919c2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions bodhi/server/schemas.py
Expand Up @@ -396,6 +396,7 @@ class SaveReleaseSchema(CSRFProtectedSchema, colander.MappingSchema):
)
override_tag = colander.SchemaNode(
colander.String(),
missing="",
)
state = colander.SchemaNode(
colander.String(),
Expand Down
5 changes: 5 additions & 0 deletions bodhi/server/validators.py
Expand Up @@ -1090,6 +1090,11 @@ def _validate_override_build(request, nvr, db):

build.release = release

if not build.release.override_tag:
request.errors.add("body", "nvr", "Cannot create a buildroot override"
" Release associated to build does not support it.")
return

for tag in build.get_tags():
if tag in (build.release.candidate_tag, build.release.testing_tag):
# The build is tagged as a candidate or testing
Expand Down
24 changes: 24 additions & 0 deletions bodhi/tests/server/test_validators.py
Expand Up @@ -518,6 +518,30 @@ def test_no_nvrs_given(self):
'description': 'A comma-separated list of NVRs is required.'}])
self.assertEqual(request.errors.status, exceptions.HTTPBadRequest.code)

def test_release_with_no_override_tag(self):
"""If the request has a build associated to a release with no override tag,
it should add an error to the request."""

build = self.db.query(models.Build).filter_by(
nvr='bodhi-2.0-1.fc17').first()

build.release.override_tag = ""
self.db.commit()

request = mock.Mock()
request.db = self.db
request.errors = Errors()
request.validated = {'nvr': 'bodhi-2.0-1.fc17', 'edited': False}

validators.validate_override_builds(request)

self.assertEqual(
request.errors,
[{'location': 'body', 'name': 'nvr',
'description': 'Cannot create a buildroot override'\
' Release associated to build does not support it.'}])
self.assertEqual(request.errors.status, exceptions.HTTPBadRequest.code)


class TestValidateRelease(BaseTestCase):
"""Test the validate_release() function."""
Expand Down

0 comments on commit 39919c2

Please sign in to comment.