mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 03:38:12 +08:00
Surface the error to the user when a module dependency can't be found
This commit is contained in:
@@ -48,7 +48,7 @@ class DBResolver(GenericResolver):
|
||||
:param context: a string of the module's context. When None, all contexts will
|
||||
be returned.
|
||||
:kwarg strict: Normally this function returns [] if no module can be
|
||||
found. If strict=True, then a ValueError is raised.
|
||||
found. If strict=True, then a UnprocessableEntity is raised.
|
||||
:return: List of Modulemd metadata instances matching the query
|
||||
"""
|
||||
with models.make_session(self.config) as session:
|
||||
@@ -63,8 +63,8 @@ class DBResolver(GenericResolver):
|
||||
"This combination of name/stream/version/context is not implemented")
|
||||
|
||||
if not builds and strict:
|
||||
raise ValueError("Cannot find any module build for %s:%s "
|
||||
"in MBS database" % (name, stream))
|
||||
raise UnprocessableEntity(
|
||||
"Cannot find any module builds for %s:%s" % (name, stream))
|
||||
return [build.mmd() for build in builds]
|
||||
|
||||
def get_module_tag(self, name, stream, version, context, strict=False):
|
||||
|
||||
17
tests/staged_data/testmodule-no-deps.yaml
Normal file
17
tests/staged_data/testmodule-no-deps.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
document: modulemd
|
||||
version: 1
|
||||
data:
|
||||
summary: A test module in all its beautiful beauty
|
||||
description: >-
|
||||
This module demonstrates how to write simple modulemd files And
|
||||
can be used for testing the build and release pipeline.
|
||||
license:
|
||||
module: [ MIT ]
|
||||
dependencies:
|
||||
buildrequires:
|
||||
chineese_food: good
|
||||
requires:
|
||||
noodles: lomein
|
||||
references:
|
||||
community: https://docs.pagure.org/modularity/
|
||||
documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules
|
||||
@@ -592,6 +592,25 @@ class TestViews:
|
||||
}
|
||||
assert data == expected_error
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
def test_submit_build_dep_not_present(self, mocked_scm, mocked_get_user):
|
||||
FakeSCM(mocked_scm, 'testmodule', 'testmodule-no-deps.yaml',
|
||||
'620ec77321b2ea7b0d67d82992dda3e1d67055b4')
|
||||
|
||||
rv = self.client.post('/module-build-service/1/module-builds/', data=json.dumps(
|
||||
{'branch': 'master',
|
||||
'scmurl': ('git://pkgs.stg.fedoraproject.org/modules/testmodule.git?'
|
||||
'#68931c90de214d9d13feefbd35246a81b6cb8d49')}))
|
||||
data = json.loads(rv.data)
|
||||
assert rv.status_code == 422
|
||||
expected_error = {
|
||||
'error': 'Unprocessable Entity',
|
||||
'message': 'Cannot find any module builds for chineese_food:good',
|
||||
'status': 422
|
||||
}
|
||||
assert data == expected_error
|
||||
|
||||
@patch('module_build_service.auth.get_user', return_value=user)
|
||||
@patch('module_build_service.scm.SCM')
|
||||
def test_submit_build_rebuild_strategy_override_not_allowed(self, mocked_scm, mocked_get_user):
|
||||
|
||||
Reference in New Issue
Block a user