Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_parsers.py
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | |||||
def test_parse_swh_reference_empty(xml_with_empty_reference, xml_ref): | def test_parse_swh_reference_empty(xml_with_empty_reference, xml_ref): | ||||
xml_body = xml_with_empty_reference.format(swh_reference=xml_ref) | xml_body = xml_with_empty_reference.format(swh_reference=xml_ref) | ||||
metadata = parse_xml(xml_body) | metadata = parse_xml(xml_body) | ||||
assert parse_swh_reference(metadata) is None | assert parse_swh_reference(metadata) is None | ||||
@pytest.fixture | @pytest.fixture | ||||
def xml_with_swhid(): | def xml_with_swhid(atom_dataset): | ||||
xml_data = """<?xml version="1.0"?> | return atom_dataset["entry-data-with-swhid"] | ||||
<entry xmlns="http://www.w3.org/2005/Atom" | |||||
xmlns:codemeta="https://doi.org/10.5063/SCHEMA/CODEMETA-2.0" | |||||
xmlns:swh="https://www.softwareheritage.org/schema/2018/deposit"> | |||||
<swh:deposit> | |||||
<swh:reference> | |||||
<swh:object swhid="{swhid}" /> | |||||
</swh:reference> | |||||
</swh:deposit> | |||||
</entry> | |||||
""" | |||||
return xml_data.strip() | |||||
@pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||
"swhid", | "swhid", | ||||
[ | [ | ||||
"swh:1:cnt:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;origin=https://hal.archives-ouvertes.fr/hal-01243573;visit=swh:1:snp:4fc1e36fca86b2070204bedd51106014a614f321;anchor=swh:1:rev:9c5de20cfb54682370a398fcc733e829903c8cba;path=/moranegg-AffectationRO-df7f68b/", # noqa | "swh:1:cnt:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;origin=https://hal.archives-ouvertes.fr/hal-01243573;visit=swh:1:snp:4fc1e36fca86b2070204bedd51106014a614f321;anchor=swh:1:rev:9c5de20cfb54682370a398fcc733e829903c8cba;path=/moranegg-AffectationRO-df7f68b/", # noqa | ||||
"swh:1:dir:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;anchor=swh:1:dir:9c5de20cfb54682370a398fcc733e829903c8cba", # noqa | "swh:1:dir:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;anchor=swh:1:dir:9c5de20cfb54682370a398fcc733e829903c8cba", # noqa | ||||
"swh:1:rev:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;anchor=swh:1:rev:9c5de20cfb54682370a398fcc733e829903c8cba", # noqa | "swh:1:rev:31b5c8cc985d190b5a7ef4878128ebfdc2358f49;anchor=swh:1:rev:9c5de20cfb54682370a398fcc733e829903c8cba", # noqa | ||||
Show All 39 Lines |