Initial version
This commit is contained in:
commit
42996b0f4e
31 changed files with 933 additions and 0 deletions
44
tests/test_formatter.py
Normal file
44
tests/test_formatter.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from citer.formatter import format_apa
|
||||
from citer.models import Author, WorkMetadata
|
||||
|
||||
|
||||
def test_format_doi_article():
|
||||
metadata = WorkMetadata(
|
||||
title="Sample study on testing",
|
||||
authors=[Author("Jane", "Doe"), Author("John", "Smith")],
|
||||
year=2020,
|
||||
container_title="Journal of Tests",
|
||||
volume="12",
|
||||
issue="3",
|
||||
pages="45-67",
|
||||
doi="10.1234/example.doi",
|
||||
url="https://doi.org/10.1234/example.doi",
|
||||
source="doi",
|
||||
identifier="10.1234/example.doi",
|
||||
)
|
||||
|
||||
citation = format_apa(metadata)
|
||||
assert (
|
||||
citation
|
||||
== "Doe, J., & Smith, J. (2020). Sample study on testing. "
|
||||
"Journal of Tests, 12(3), 45-67. https://doi.org/10.1234/example.doi"
|
||||
)
|
||||
|
||||
|
||||
def test_format_arxiv_preprint():
|
||||
metadata = WorkMetadata(
|
||||
title="Deep learning for cats",
|
||||
authors=[Author("Alice", "Nguyen"), Author("Bob", "Smith")],
|
||||
year=2021,
|
||||
container_title="arXiv preprint",
|
||||
url="https://arxiv.org/abs/2101.00001",
|
||||
source="arxiv",
|
||||
identifier="2101.00001",
|
||||
)
|
||||
|
||||
citation = format_apa(metadata)
|
||||
assert (
|
||||
citation
|
||||
== "Nguyen, A., & Smith, B. (2021). Deep learning for cats. "
|
||||
"arXiv preprint, arXiv:2101.00001. https://arxiv.org/abs/2101.00001"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue