def test_meta(self): doc = Document( { 'og': { 'title': ['Example Page'], 'url': ['http://example.com'] }, 'title': ['Example Page'], 'link': ['http://example.com', 'https://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 = [ DocumentMeta({ 'type': 'og.title', 'value': ['Example Page'], 'claimant': 'http://example.com', 'created': datetime.datetime(2016, 2, 25, 16, 45, 23, 371848), 'updated': datetime.datetime(2016, 2, 25, 16, 45, 23, 371849) }), DocumentMeta({ 'type': 'og.url', 'value': ['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) }), DocumentMeta({ 'type': 'title', 'value': ['Example Page'], 'claimant': 'http://example.com', 'created': datetime.datetime(2016, 2, 25, 16, 45, 23, 371848), 'updated': datetime.datetime(2016, 2, 25, 16, 45, 23, 371849) }) ] assert sorted(doc.meta) == sorted(expected)
def test_normalized_type_normalizes_og(self): meta = DocumentMeta({'type': 'og.title'}) assert meta.normalized_type == 'facebook.title'
def test_normalized_type_normalizes_colons(self): meta = DocumentMeta({'type': 'facebook.book:isbn'}) assert meta.normalized_type == 'facebook.book.isbn'
def test_normalized_type_normalizes_case(self): meta = DocumentMeta({'type': 'dc.Contributor.Sponsor'}) assert meta.normalized_type == 'dc.contributor.sponsor'
def test_normalized_type_normalizes_multiple_dots(self): meta = DocumentMeta({'type': 'dc..description'}) assert meta.normalized_type == 'dc.description'
def test_value(self): meta = DocumentMeta({'value': 'Example Page'}) assert meta.value == 'Example Page'
def test_type_skips_og_normalisation(self, type): meta = DocumentMeta({'type': type}) assert meta.type == type
def test_type(self): meta = DocumentMeta({'type': 'title'}) assert meta.type == 'title'
def test_claimant_normalized(self): meta = DocumentMeta({'claimant': 'http://example.com/'}) assert meta.claimant_normalized == 'http://example.com'
def test_claimant(self): meta = DocumentMeta({'claimant': 'http://example.com'}) assert meta.claimant == 'http://example.com'
def test_updated(self): meta = DocumentMeta( {'updated': datetime.datetime(2016, 2, 25, 16, 45, 23, 371848)}) assert meta.updated == datetime.datetime(2016, 2, 25, 16, 45, 23, 371848)