linkcell with link_page and anchor: add tests (#7400)

This commit is contained in:
Thomas NOËL 2015-05-29 15:36:55 +02:00
parent 64e5c82c60
commit e53d411fb2
1 changed files with 24 additions and 4 deletions

View File

@ -39,18 +39,38 @@ def test_additional_label():
assert '...' in cell.get_additional_label()
def test_link_cell():
page = Page()
page = Page(title='example page', slug='example-page')
page.save()
cell = LinkCell()
cell.page = page
cell.title = 'Example Site'
cell.url = 'http://example.net'
cell.url = 'http://example.net/'
cell.order = 0
cell.save()
assert cell.get_additional_label() == 'Example Site'
from django.template import Context
ctx = Context()
assert cell.render(ctx).strip() == '<a href="http://example.net">Example Site</a>'
assert cell.render(ctx).strip() == '<a href="http://example.net/">Example Site</a>'
assert cell.get_additional_label() == 'Example Site'
cell.title = ''
cell.save()
assert cell.render(ctx).strip() == '<a href="http://example.net/">http://example.net/</a>'
cell.link_page = page
cell.save()
assert cell.render(ctx).strip() == '<a href="/example-page">example page</a>'
cell.title = 'altertitle'
cell.save()
assert cell.render(ctx).strip() == '<a href="/example-page">altertitle</a>'
cell.anchor = 'anchor'
cell.save()
assert cell.render(ctx).strip() == '<a href="/example-page#anchor">altertitle</a>'
cell.link_page = None
cell.save()
assert cell.render(ctx).strip() == '<a href="http://example.net/#anchor">altertitle</a>'