Exemplo n.º 1
0
 def test_it_ignores_invalid_dois(self):
     """If `doi_uri_from_string` returns `None`, the identifier is ignored."""
     highwire_dict = {"doi": ["doi:"]}
     document_uris = document_claims.document_uris_from_highwire_doi(
         highwire_dict, claimant="http://example.com/example.html"
     )
     assert len(document_uris) == 0
Exemplo n.º 2
0
    def test_whitespace_is_stripped_from_dois(self):
        for doi in (' foo ', 'doi: foo ', ' doi:foo ', ' doi: foo '):
            highwire_dict = {'doi': [doi]}

            document_uris = 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']
Exemplo n.º 3
0
    def test_whitespace_only_dois_are_ignored(self):
        for doi in (' ', 'doi: '):
            highwire_dict = {'doi': [doi]}

            document_uris = document_claims.document_uris_from_highwire_doi(
                highwire_dict,
                claimant='http://example.com/example.html',
            )

            assert document_uris == []
Exemplo n.º 4
0
    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 = 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])
Exemplo n.º 5
0
    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 = 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': '',
            }
Exemplo n.º 6
0
    def test_highwire_doi_values_produce_highwire_doi_document_uris(self):
        highwire_dict = {
            "doi": [
                "doi:10.1038/nphys1170",
                "doi:10.1002/0470841559.ch1",
                "doi:10.1594/PANGAEA.726855",
            ]
        }

        document_uris = 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": "",
            }