diff --git a/swh/deposit/api/checks.py b/swh/deposit/api/checks.py --- a/swh/deposit/api/checks.py +++ b/swh/deposit/api/checks.py @@ -35,10 +35,9 @@ for field, value in metadata.items(): for possible_names in alternate_fields: - for possible_name in possible_names: - if possible_name in field: - alternate_fields[possible_names] = True - continue + if field in possible_names: + alternate_fields[possible_names] = True + continue mandatory_result = [" or ".join(k) for k, v in alternate_fields.items() if not v] diff --git a/swh/deposit/tests/api/test_checks.py b/swh/deposit/tests/api/test_checks.py --- a/swh/deposit/tests/api/test_checks.py +++ b/swh/deposit/tests/api/test_checks.py @@ -81,6 +81,18 @@ "fields": ["atom:author or codemeta:author"], }, ), + ( + { + "atom:url": "something", + "atom:external_identifier": "something-else", + "atom:title": "foobar", + "atom:authorblahblah": "foo", + }, + { + "summary": "Mandatory fields are missing", + "fields": ["atom:author or codemeta:author"], + }, + ), ], ) def test_api_checks_check_metadata_ko(