def test_doi_missing_internet(self, disable_socket):
"""Ensure that DOI validation fails gracefully with no Internet.
"""
root = etree.Element('experiment')
ref = etree.SubElement(root, 'bibliographyLink')
ref.set('doi', '10.1016/j.ijhydene.2007.04.008')
ref.set('preferredKey', 'Chaumeix, N., Pichon, S., Lafosse, F., Paillard, C.-E., '
'International Journal of Hydrogen Energy, 2007, (32) 2216-2226, '
'Fig. 12., right, open diamond'
)
with pytest.warns(UserWarning) as record:
ref = get_reference(root)
m = str(record.pop(UserWarning).message)
assert m == ('Missing doi attribute in bibliographyLink or lookup failed. Setting "detail" '
'key as a fallback; please update to the appropriate fields.')
assert ref['detail'] == ('Chaumeix, N., Pichon, S., Lafosse, F., Paillard, C.-E., '
'International Journal of Hydrogen Energy, 2007, (32) 2216-2226, '
'Fig. 12., right, open diamond.'
)
评论列表
文章目录