1234567891011121314151617181920212223242526 |
- import unittest.mock
- from pubmed_bibtex import bibtex_entry_from_pmid, main
- TEST_PMID = '31025164'
- TEST_BIBTEX_ENTRY = r"""@Article{pmid31025164,
- Author="Egger, F. and Hofer, C. and Hammerle, F. P. and Lofler, S. and Nurnberg, M. and Fiedler, L. and Kriz, R. and Kern, H. and Huber, K. ",
- Title="{{I}nfluence of electrical stimulation therapy on permanent pacemaker function}",
- Journal="Wien. Klin. Wochenschr.",
- Year="2019",
- Month="Apr",
- Note={[DOI:\href{https://dx.doi.org/10.1007/s00508-019-1494-5}{10.1007/s00508-019-1494-5}] [PubMed:\href{https://www.ncbi.nlm.nih.gov/pubmed/31025164}{31025164}] }
- }
- """
- def test_bibtex_entry_from_pmid():
- assert bibtex_entry_from_pmid(pmid=TEST_PMID) == TEST_BIBTEX_ENTRY
- def test_main(capsys):
- with unittest.mock.patch('sys.argv', ['', TEST_PMID]):
- main()
- out, err = capsys.readouterr()
- assert not err
- assert out == TEST_BIBTEX_ENTRY
|