self = <swh.indexer.tests.test_metadata.TestMetadata object at 0x7fe69ffb24a8>
def test_compute_metadata_cff_list(self):
"""
test yaml translation for empty yaml file
"""
# given
content = """
- Foo
- Bar
""".encode(
"utf-8"
)
expected = None
> result = self.cff_mapping.translate(content)
.tox/py3/lib/python3.7/site-packages/swh/indexer/tests/test_metadata.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/indexer/metadata_dictionary/cff.py:33: in translate
content_dict_checked = self.value_type_check(content_dict)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.indexer.metadata_dictionary.cff.CffMapping object at 0x7fe687f944e0>
content_dict = ['Foo', 'Bar']
def value_type_check(self, content_dict):
type_checked_content_dict = {}
for field in content_dict:
if field == "authors":
authors = []
for author in content_dict["authors"]:
author_checked = {}
if isinstance(author["given-names"], str):
author_checked["given-names"] = author["given-names"]
if isinstance(author["name-particle"], str):
author_checked["name-particle"] = author["name-particle"]
# will add the rest if what I'm doing is correct...
# Check if the given author email keeps with the re of emails
if bool(
re.match(
r"([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+",
author["email"],
)
):
author_checked["email"] = author["email"]
for subField in author:
if not (
subField == "given-names"
or subField == "name-particle"
or subField == "email"
):
author_checked[subField] = author[subField]
authors.append(author_checked)
type_checked_content_dict["authors"] = authors
else:
> type_checked_content_dict[field] = content_dict[field]
E TypeError: list indices must be integers or slices, not str
.tox/py3/lib/python3.7/site-packages/swh/indexer/metadata_dictionary/cff.py:82: TypeError
TEST RESULT
TEST RESULT
- Run At
- Jun 24 2022, 8:06 PM