def test_whitespace_is_stripped_from_dois(self): for doi in (' foo ', 'doi: foo ', ' doi:foo ', ' doi: foo '): highwire_dict = {'doi': [doi]} document_uris = parse_document_claims.document_uris_from_highwire_doi( highwire_dict, claimant='http://example.com/example.html', ) assert [d['uri'] for d in document_uris] == ['doi:foo']
def test_whitespace_only_dois_are_ignored(self): for doi in (' ', 'doi: '): highwire_dict = {'doi': [doi]} document_uris = parse_document_claims.document_uris_from_highwire_doi( highwire_dict, claimant='http://example.com/example.html', ) assert document_uris == []
def test_doi_is_prepended_to_highwire_dois(self): """If a highwire DOI doesn't begin with 'doi:' it is prepended.""" highwire_dict = {'doi': ['10.10.1038/nphys1170']} document_uris = parse_document_claims.document_uris_from_highwire_doi( highwire_dict, claimant='http://example.com/example.html', ) expected_uri = 'doi:' + highwire_dict['doi'][0] one([d for d in document_uris if d.get('uri') == expected_uri])
def test_highwire_doi_values_produce_highwire_doi_document_uris(self): highwire_dict = { 'doi': ['doi:10.10.1038/nphys1170', 'doi:10.1002/0470841559.ch1', 'doi:10.1594/PANGAEA.726855'], } document_uris = parse_document_claims.document_uris_from_highwire_doi( highwire_dict, claimant='http://example.com/example.html', ) for doi in highwire_dict['doi']: document_uri = one([d for d in document_uris if d.get('uri') == doi]) assert document_uri == { 'claimant': 'http://example.com/example.html', 'uri': doi, 'type': 'highwire-doi', 'content_type': '', }