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)
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)
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)
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
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
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
def test_content_type(self): docuri = DocumentURI({'content_type': 'application/pdf'}) assert docuri.content_type == 'application/pdf'
def test_type(self): docuri = DocumentURI({'type': 'rel-canonical'}) assert docuri.type == 'rel-canonical'
def test_uri_normalized(self): docuri = DocumentURI({'uri': 'http://example.com/'}) assert docuri.uri_normalized == 'http://example.com'
def test_uri(self): docuri = DocumentURI({'uri': 'http://example.com'}) assert docuri.uri == 'http://example.com'
def test_claimant_normalized(self): docuri = DocumentURI({'claimant': 'http://example.com/'}) assert docuri.claimant_normalized == 'http://example.com'
def test_claimant(self): docuri = DocumentURI({'claimant': 'http://example.com'}) assert docuri.claimant == 'http://example.com'
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)