modules: Correctly report error for unexpected modules

The code checked with `assert` that there is only one module matching
given NSV. In actual package that would not do anything and we would
silently pick the first value.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-04-26 09:24:47 +02:00
parent b8555b7869
commit 68f80751cf

View File

@ -119,15 +119,15 @@ def variant_dict_from_str(compose, module_str):
@retry(wait_on=IOError) @retry(wait_on=IOError)
def get_module(compose, session, module_info): def get_module(compose, session, module_info_str):
""" """
:param session : PDCClient instance :param session : PDCClient instance
:param module_info: pdc variant_dict, str, mmd or module dict :param module_info_str: pdc variant_dict, str, mmd or module dict
:return final list of module_info which pass repoclosure :return final list of module_info which pass repoclosure
""" """
module_info = variant_dict_from_str(compose, module_info) module_info = variant_dict_from_str(compose, module_info_str)
query = dict( query = dict(
name=module_info['name'], name=module_info['name'],
@ -150,7 +150,9 @@ def get_module(compose, session, module_info):
# returned, but otherwise we have to pick the one with the highest # returned, but otherwise we have to pick the one with the highest
# release ourselves. # release ourselves.
if 'version' in query: if 'version' in query:
assert len(retval) <= 1, "More than one module returned from PDC: %s" % retval if len(retval) > 1:
raise RuntimeError("More than one module returned from PDC for %s: %s"
% (module_info_str, retval))
module = retval[0] module = retval[0]
else: else:
module = retval[0] module = retval[0]