Exemplo n.º 1
0
def test_no_page(wrf, site, identity):
    metadata = Metadata(request=wrf.get('/'), site=site)

    assert metadata.title is None
    assert metadata.site_title == identity.name
    assert metadata.full_title == identity.name
    assert metadata.description == identity.description
Exemplo n.º 2
0
def test_from_context(wrf, page, site, identity):
    ctx = {'request': wrf.get('/'), 'page': page, 'site': site}
    metadata = Metadata(ctx)

    assert metadata.title == page.seo_title
    assert metadata.site_title == identity.name
    assert metadata.full_title == ' | '.join((page.seo_title, identity.name))
    assert metadata.description == page.search_description
Exemplo n.º 3
0
def blog_meta(context):
    ctx = context.get_all()
    request = context['request']
    site = get_site(request)
    ctx['blogs'] = [
        b for b in Blog.objects.live()
        if getattr(b.get_site(), 'pk', None) == site.pk
    ]
    ctx['meta'] = Metadata(ctx)
    return ctx
Exemplo n.º 4
0
def test_from_kwargs(wrf, page, site, identity):
    metadata = Metadata(request=wrf.get('/'), page=page, site=site)

    assert metadata.title == page.seo_title
    assert metadata.site_title == identity.name
    assert metadata.full_title == ' | '.join((page.seo_title, identity.name))
    assert metadata.description == page.search_description
    assert metadata.image is None
    assert metadata.image_url is None
    assert len(metadata.tags) == 3
Exemplo n.º 5
0
def test_image_url_from_kwargs(wrf, page, site, faker):
    url = faker.url()
    metadata = Metadata(request=wrf.get('/'), page=page, site=site, image_url=url)

    assert metadata.image_url == url
Exemplo n.º 6
0
def test_image_from_kwargs(wrf, page, site, image):
    metadata = Metadata(request=wrf.get('/'), page=page, site=site, image=image)

    assert metadata.image == image
Exemplo n.º 7
0
def test_page_image(wrf, static_page, site, identity):
    metadata = Metadata(request=wrf.get('/'), page=static_page, site=site)

    assert metadata.image == static_page.image
Exemplo n.º 8
0
def test_tags(wrf, static_page, site, identity):
    metadata = Metadata(request=wrf.get('/'), page=static_page, site=site, tags=['tag-1', 'tag-2'])

    assert metadata.tags == {'tag-1', 'tag-2', 'static-1', 'static-2', 'identity-1', 'identity-2'}
Exemplo n.º 9
0
def test_no_search_description(wrf, page, site, identity):
    metadata = Metadata(request=wrf.get('/'), page=page, site=site)

    assert metadata.description == identity.description
Exemplo n.º 10
0
def test_no_seo_title(wrf, page, site, identity):
    metadata = Metadata(request=wrf.get('/'), page=page, site=site)

    assert metadata.title == page.title
Exemplo n.º 11
0
def test_description_from_kwargs(wrf, page, site, faker):
    description = faker.paragraph()
    metadata = Metadata(request=wrf.get('/'), page=page, site=site, description=description)

    assert metadata.description == description
Exemplo n.º 12
0
def test_title_from_kwargs(wrf, page, site, faker):
    title = faker.sentence()
    metadata = Metadata(request=wrf.get('/'), page=page, site=site, title=title)

    assert metadata.title == title
Exemplo n.º 13
0
def test_no_image(wrf, page, site, full_identity):
    metadata = Metadata(request=wrf.get('/'), page=page, site=site)

    assert metadata.image == full_identity.logo
    assert metadata.image_url == site.root_url + get_image_url(full_identity.logo, 'original')