metadata_ko = '<entry xmlns="http://www.w3.org/2005/Atom"\n xmlns:swh="https://www.softwareheritage.org/schema/2018/deposit"\n...hema:url>some-metadata-provenance-url</schema:url>\n </swh:metadata-provenance>\n </swh:deposit>\n</entry>\n'
expected_summaries = [{'fields': ['codemeta:author'], 'summary': '.*Reason: affiliation does not have a <codemeta:name> element.*'}]
swh_checks_deposit = <swh.deposit.api.private.deposit_check.APIChecks object at 0x7fdfec6a6588>
@pytest.mark.parametrize("metadata_ko,expected_summaries", _parameters3)
def test_api_checks_check_metadata_ko_schema(
metadata_ko, expected_summaries, swh_checks_deposit
):
actual_check, error_detail = check_metadata(ElementTree.fromstring(metadata_ko))
assert actual_check is False
assert len(error_detail["metadata"]) == len(expected_summaries), error_detail[
"metadata"
]
for (detail, expected_summary) in zip(error_detail["metadata"], expected_summaries):
assert detail["fields"] == expected_summary["fields"]
# xmlschema returns very detailed errors, we cannot reasonably test them
# for equality
summary = detail["summary"]
> assert re.match(
expected_summary["summary"], summary, re.DOTALL
), f"Failed to match {expected_summary['summary']!r} with:\n{summary}"
E AssertionError: Failed to match '.*Reason: affiliation does not have a <codemeta:name> element.*' with:
E failed validating <Element '{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}affiliation' at 0x7fdfec6bb048> with Xsd11Group(model='all', occurs=[1, 1]):
E
E Reason: The content of element 'codemeta:affiliation' is not complete. Tag 'codemeta:name' expected.
E
E Schema:
E
E <xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PersonOrOrganization">
E
E <xsd:all>
E <xsd:element ref="codemeta:name" />
E <xsd:any maxOccurs="unbounded" minOccurs="0" processContents="lax" />
E </xsd:all>
E </xsd:complexType>
E
E Instance:
E
E <codemeta:affiliation xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0">
E </codemeta:affiliation>
E
E Path: /{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}author/{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}affiliation
E
E assert None
E + where None = <function match at 0x7fdff654bbf8>('.*Reason: affiliation does not have a <codemeta:name> element.*', "failed validating <Element '{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}affiliation' at 0x7fdfec6bb048> with Xsd11Gr...nPath: /{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}author/{https://doi.org/10.5063/SCHEMA/CODEMETA-2.0}affiliation\n", <RegexFlag.DOTALL: 16>)
E + where <function match at 0x7fdff654bbf8> = re.match
E + and <RegexFlag.DOTALL: 16> = re.DOTALL
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_checks.py:1053: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Mar 8 2022, 5:51 PM