Esempio n. 1
0
    def test_uris_prefix_type_when_rel(self):
        doc = Document(
            {'link': [{
                'href': 'https://example.com',
                'rel': 'canonical'
            }]},
            claimant='http://example.com')

        expected = [
            DocumentURI({
                'claimant': 'http://example.com',
                'uri': 'https://example.com',
                'type': 'rel-canonical',
                'content_type': None,
                'created': None,
                'updated': None
            }),
            DocumentURI({
                'claimant': 'http://example.com',
                'uri': 'http://example.com',
                'type': 'self-claim',
                'created': None,
                'updated': None
            })
        ]

        assert sorted(doc.document_uris) == sorted(expected)
Esempio n. 2
0
    def test_uris_recognize_highwire_pdf(self):
        doc = Document(
            {'link': [{
                'href': 'pdf-uri',
                'type': 'application/pdf'
            }]},
            claimant='http://example.com')

        expected = [
            DocumentURI({
                'claimant': 'http://example.com',
                'uri': 'pdf-uri',
                'type': 'highwire-pdf',
                'content_type': 'application/pdf',
                'created': None,
                'updated': None
            }),
            DocumentURI({
                'claimant': 'http://example.com',
                'uri': 'http://example.com',
                'type': 'self-claim',
                'created': None,
                'updated': None
            })
        ]

        assert sorted(doc.document_uris) == sorted(expected)
Esempio n. 3
0
    def test_uris_generates_doi_uri_from_dc_meta(self, doc):
        expected = [DocumentURI({'claimant': 'http://example.com',
                                 'uri': 'doi:foobar',
                                 'type': 'dc-doi',
                                 'created': None, 'updated': None}),

                    DocumentURI({'claimant': 'http://example.com',
                                 'uri': 'http://example.com',
                                 'type': 'self-claim',
                                 'created': None, 'updated': None})]

        assert sorted(doc.document_uris) == sorted(expected)
Esempio n. 4
0
    def test_uris_only_one_self_claim(self):
        doc = Document({'link': [{'href': 'http://example.com'}]},
                       claimant='http://example.com')

        expected = [DocumentURI({'claimant': 'http://example.com',
                                 'uri': 'http://example.com',
                                 'type': 'self-claim',
                                 'created': None, 'updated': None})]

        assert doc.document_uris == expected
Esempio n. 5
0
 def test_uris_discard_self_claim_when_claimant_is_missing(self):
     doc = Document({'link': [{'href': 'http://example.com'}]})
     expected = [
         DocumentURI({
             'claimant': None,
             'uri': 'http://example.com',
             'type': None,
             'content_type': None,
             'created': None,
             'updated': None
         })
     ]
     assert doc.document_uris == expected
Esempio n. 6
0
    def test_uris_str_link(self):
        doc = Document({'link': 'http://example.com'},
                       claimant='http://example.com',
                       created=datetime.datetime(2016, 2, 25, 16, 45, 23, 371848),
                       updated=datetime.datetime(2016, 2, 25, 16, 45, 23, 371849))

        expected = [DocumentURI({'claimant': 'http://example.com',
                                 'uri': 'http://example.com',
                                 'type': 'self-claim',
                                 'created': datetime.datetime(2016, 2, 25, 16, 45, 23, 371848),
                                 'updated': datetime.datetime(2016, 2, 25, 16, 45, 23, 371849)})]

        assert doc.document_uris == expected
Esempio n. 7
0
 def test_content_type(self):
     docuri = DocumentURI({'content_type': 'application/pdf'})
     assert docuri.content_type == 'application/pdf'
Esempio n. 8
0
 def test_type(self):
     docuri = DocumentURI({'type': 'rel-canonical'})
     assert docuri.type == 'rel-canonical'
Esempio n. 9
0
 def test_uri_normalized(self):
     docuri = DocumentURI({'uri': 'http://example.com/'})
     assert docuri.uri_normalized == 'http://example.com'
Esempio n. 10
0
 def test_uri(self):
     docuri = DocumentURI({'uri': 'http://example.com'})
     assert docuri.uri == 'http://example.com'
Esempio n. 11
0
 def test_claimant_normalized(self):
     docuri = DocumentURI({'claimant': 'http://example.com/'})
     assert docuri.claimant_normalized == 'http://example.com'
Esempio n. 12
0
 def test_claimant(self):
     docuri = DocumentURI({'claimant': 'http://example.com'})
     assert docuri.claimant == 'http://example.com'
Esempio n. 13
0
 def test_updated(self):
     docuri = DocumentURI(
         {'updated': datetime.datetime(2016, 2, 25, 16, 45, 23, 371848)})
     assert docuri.updated == datetime.datetime(2016, 2, 25, 16, 45, 23,
                                                371848)