Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/api/test_checks.py
Show All 18 Lines | [ | ||||
}, | }, | ||||
{ | { | ||||
"atom:url": "some url", | "atom:url": "some url", | ||||
"atom:external_identifier": "some id", | "atom:external_identifier": "some id", | ||||
"atom:title": "bar", | "atom:title": "bar", | ||||
"atom:author": "no one", | "atom:author": "no one", | ||||
}, | }, | ||||
{"atom:url": "some url", "codemeta:name": "bar", "codemeta:author": "no one",}, | {"atom:url": "some url", "codemeta:name": "bar", "codemeta:author": "no one",}, | ||||
{ | |||||
"atom:url": "some url", | |||||
"atom:external_identifier": "some id", | |||||
"atom:title": "bar", | |||||
"atom:author": "no one", | |||||
"codemeta:datePublished": "2020-12-21", | |||||
"codemeta:dateCreated": "2020-12-21", | |||||
}, | |||||
], | ], | ||||
) | ) | ||||
def test_api_checks_check_metadata_ok(metadata_ok, swh_checks_deposit): | def test_api_checks_check_metadata_ok(metadata_ok, swh_checks_deposit): | ||||
actual_check, detail = check_metadata(metadata_ok) | actual_check, detail = check_metadata(metadata_ok) | ||||
assert actual_check is True, detail | assert actual_check is True, detail | ||||
assert detail is None | assert detail is None | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | [ | ||||
"atom:title": "foobar", | "atom:title": "foobar", | ||||
"atom:authorblahblah": "foo", | "atom:authorblahblah": "foo", | ||||
}, | }, | ||||
{ | { | ||||
"summary": "Mandatory fields are missing", | "summary": "Mandatory fields are missing", | ||||
"fields": ["atom:author or codemeta:author"], | "fields": ["atom:author or codemeta:author"], | ||||
}, | }, | ||||
), | ), | ||||
( | |||||
{ | |||||
"atom:url": "some url", | |||||
"atom:external_identifier": "some id", | |||||
"atom:title": "bar", | |||||
"atom:author": "no one", | |||||
"codemeta:datePublished": "2020-aa-21", | |||||
"codemeta:dateCreated": "2020-12-bb", | |||||
}, | |||||
{ | |||||
"summary": "Invalid date format", | |||||
"fields": ["codemeta:datePublished", "codemeta:dateCreated"], | |||||
}, | |||||
), | |||||
], | ], | ||||
) | ) | ||||
def test_api_checks_check_metadata_ko( | def test_api_checks_check_metadata_ko( | ||||
metadata_ko, expected_summary, swh_checks_deposit | metadata_ko, expected_summary, swh_checks_deposit | ||||
): | ): | ||||
"""Missing optional field should be caught | |||||
""" | |||||
actual_check, error_detail = check_metadata(metadata_ko) | actual_check, error_detail = check_metadata(metadata_ko) | ||||
assert actual_check is False | assert actual_check is False | ||||
assert error_detail == {"metadata": [expected_summary]} | assert error_detail == {"metadata": [expected_summary]} |