test_bibtex_entry_from_pmid.py 936 B

1234567891011121314151617181920212223242526
  1. import unittest.mock
  2. from pubmed_bibtex import bibtex_entry_from_pmid, _main
  3. TEST_PMID = '31025164'
  4. TEST_BIBTEX_ENTRY = r"""@Article{pmid31025164,
  5. 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. ",
  6. Title="{{I}nfluence of electrical stimulation therapy on permanent pacemaker function}",
  7. Journal="Wien. Klin. Wochenschr.",
  8. Year="2019",
  9. Month="Apr",
  10. 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}] }
  11. }
  12. """
  13. def test_bibtex_entry_from_pmid():
  14. assert bibtex_entry_from_pmid(pmid=TEST_PMID) == TEST_BIBTEX_ENTRY
  15. def test_main(capsys):
  16. with unittest.mock.patch('sys.argv', ['', TEST_PMID]):
  17. _main()
  18. out, err = capsys.readouterr()
  19. assert not err
  20. assert out == TEST_BIBTEX_ENTRY