def test_full_static_page(wrf, site, identity, static_page_factory): page = static_page_factory(published=True, owned=True, full=True, tags=3) data = jsonld.graph({'request': wrf.get('/')}, page) assert len(jsonld.extract(data['@graph'], 'Article')) == 1 graph = jsonld.extract_first(data['@graph'], 'Article') assert graph['keywords'] == ','.join(t.name for t in page.tags.all())
def test_minimal_album(wrf, site, identity, album): data = jsonld.graph({'request': wrf.get('/')}, album) assert len(jsonld.extract(data['@graph'], 'ImageGallery')) == 1 graph = jsonld.extract_first(data['@graph'], 'ImageGallery') assert graph['@id'] == album.full_url assert graph['name'] == album.seo_title
def test_minimal_gallery(wrf, site, identity, gallery): data = jsonld.graph({'request': wrf.get('/')}, gallery) assert len(jsonld.extract(data['@graph'], 'CollectionPage')) == 1 graph = jsonld.extract_first(data['@graph'], 'CollectionPage') assert graph['@id'] == gallery.full_url assert graph['url'] == gallery.full_url assert graph['name'] == gallery.seo_title
def test_faq_static_page(wrf, site, identity, static_page): data = jsonld.graph({'request': wrf.get('/')}, static_page) assert len(jsonld.extract(data['@graph'], 'FAQPage')) == 1 graph = jsonld.extract_first(data['@graph'], 'FAQPage') assert graph['@id'] == static_page.full_url assert graph['url'] == static_page.full_url assert graph['name'] == static_page.seo_title
def test_minimal_static_page(wrf, site, identity, static_page): data = jsonld.graph({'request': wrf.get('/')}, static_page) assert len(jsonld.extract(data['@graph'], 'Article')) == 1 graph = jsonld.extract_first(data['@graph'], 'Article') assert graph['@id'] == static_page.full_url assert graph['url'] == static_page.full_url assert graph['name'] == static_page.seo_title assert 'keywords' not in graph
def test_minimal_blog(wrf, site, identity, blog): data = jsonld.graph({'request': wrf.get('/')}, blog) assert len(jsonld.extract(data['@graph'], 'Blog')) == 1 graph = jsonld.extract_first(data['@graph'], 'Blog') assert graph['@id'] == blog.full_url assert graph['url'] == blog.full_url assert graph['name'] == blog.seo_title assert graph['description'] == blog.intro
def test_minimal_blogpost(wrf, site, identity, blog_post): data = jsonld.graph({'request': wrf.get('/')}, blog_post) assert len(jsonld.extract(data['@graph'], 'BlogPosting')) == 1 graph = jsonld.extract_first(data['@graph'], 'BlogPosting') assert graph['@id'] == blog_post.full_url assert graph['url'] == blog_post.full_url assert graph['mainEntityOfPage'] == blog_post.full_url assert graph['name'] == blog_post.seo_title assert graph['description'] == blog_post.summarize(140)
def test_published_blog(wrf, site, identity, blog): data = jsonld.graph({'request': wrf.get('/')}, blog) assert len(jsonld.extract(data['@graph'], 'Blog')) == 1 graph = jsonld.extract_first(data['@graph'], 'Blog') assert graph['@id'] == blog.full_url assert graph['url'] == blog.full_url assert graph['name'] == blog.seo_title assert graph['description'] == blog.intro assert graph['datePublished'] == blog.first_published_at.isoformat() assert graph['dateModified'] == blog.last_published_at.isoformat()
def test_full_gallery_with_albums(wrf, site, identity, gallery_factory, album_factory): gallery = gallery_factory(full=True, published=True) albums = album_factory.create_batch(3, full=True, published=True, parent=gallery) data = jsonld.graph({'request': wrf.get('/')}, gallery) assert len(jsonld.extract(data['@graph'], 'CollectionPage')) == 1 graph = jsonld.extract_first(data['@graph'], 'CollectionPage') assert graph['@id'] == gallery.full_url assert graph['url'] == gallery.full_url assert graph['name'] == gallery.seo_title assert 'hasPart' in graph assert len(graph['hasPart']) == len(albums) for part in graph['hasPart']: assert part['@type'] == 'ImageGallery'
def test_full_blogpost(wrf, site, identity, blog_post_factory): blog_post = blog_post_factory(full=True, owned=True, tags=3, published=True) data = jsonld.graph({'request': wrf.get('/')}, blog_post) assert len(jsonld.extract(data['@graph'], 'BlogPosting')) == 1 graph = jsonld.extract_first(data['@graph'], 'BlogPosting') assert graph['@id'] == blog_post.full_url assert graph['url'] == blog_post.full_url assert graph['mainEntityOfPage'] == blog_post.full_url assert graph['name'] == blog_post.seo_title assert graph['description'] == blog_post.summarize(140) assert graph['keywords'] == ','.join(t.name for t in blog_post.tags.all()) assert 'author' in graph assert graph['author']['@type'] == 'Person' assert graph['author']['name'] == blog_post.owner.get_full_name()
def test_minimal(wrf, site, identity): data = jsonld.graph({'request': wrf.get('/')}) assert data['@context'] == 'http://schema.org/' assert len(data['@graph']) == 2 assert len(jsonld.extract(data['@graph'], 'WebSite')) == 1 site_graph = jsonld.extract_first(data['@graph'], 'WebSite') assert site_graph['name'] == site.site_name assert site_graph['alternateName'] == identity.description assert site_graph['keywords'] == ','.join(t.name for t in identity.tags.all()) assert site_graph['url'] == site.root_url assert len(jsonld.extract(data['@graph'], 'Organization')) == 1 org_graph = jsonld.extract_first(data['@graph'], 'Organization') assert org_graph['url'] == site.root_url assert org_graph['name'] == identity.name