1
0
mirror of https://github.com/ilri/csv-metadata-quality.git synced 2024-12-26 22:14:29 +01:00

tests/test_check.py: add tests for title in citation

This commit is contained in:
Alan Orth 2021-12-05 16:01:11 +02:00
parent 01b4354a14
commit e02678cd7c
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -402,3 +402,39 @@ def test_check_doi_only_in_citation(capsys):
captured.out
== f"{Fore.YELLOW}DOI in citation, but missing a DOI field: {Fore.RESET}{citation}\n"
)
def test_title_in_citation():
"""Test an item with its title in the citation."""
title = "Testing all the things"
citation = "Orth, A. 2021. Testing all the things."
# Emulate a column in a transposed dataframe (which is just a series), with
# the title and citation.
d = {"dc.title": title, "dcterms.bibliographicCitation": citation}
series = pd.Series(data=d)
result = check.title_in_citation(series)
assert result == None
def test_title_not_in_citation(capsys):
"""Test an item with its title missing from the citation."""
title = "Testing all the things"
citation = "Orth, A. 2021. Testing all teh things."
# Emulate a column in a transposed dataframe (which is just a series), with
# the title and citation.
d = {"dc.title": title, "dcterms.bibliographicCitation": citation}
series = pd.Series(data=d)
check.title_in_citation(series)
captured = capsys.readouterr()
assert (
captured.out
== f"{Fore.YELLOW}Title is not present in citation: {Fore.RESET}{title}\n"
)