kopia lustrzana https://github.com/wagtail/wagtail
Add test case for `pageurl` not being called with a page
rodzic
14be13391d
commit
0b44b20367
|
@ -204,12 +204,12 @@ class TestPageUrlTags(TestCase):
|
|||
|
||||
def test_fullpageurl(self):
|
||||
tpl = template.Template(
|
||||
"""{% load wagtailcore_tags %}<a href="{% fullpageurl page %}">Fallback</a>"""
|
||||
"""{% load wagtailcore_tags %}<a href="{% fullpageurl page %}">Events</a>"""
|
||||
)
|
||||
page = Page.objects.get(url_path="/home/events/")
|
||||
with self.assertNumQueries(7):
|
||||
result = tpl.render(template.Context({"page": page}))
|
||||
self.assertIn('<a href="http://localhost/events/">Fallback</a>', result)
|
||||
self.assertIn('<a href="http://localhost/events/">Events</a>', result)
|
||||
|
||||
def test_fullpageurl_with_named_url_fallback(self):
|
||||
tpl = template.Template(
|
||||
|
@ -229,6 +229,20 @@ class TestPageUrlTags(TestCase):
|
|||
)
|
||||
self.assertIn('<a href="http://localhost/fallback/">Fallback</a>', result)
|
||||
|
||||
def test_fullpageurl_with_invalid_page(self):
|
||||
tpl = template.Template(
|
||||
"""{% load wagtailcore_tags %}<a href="{% fullpageurl page %}">Events</a>"""
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
tpl.render(template.Context({"page": 123}))
|
||||
|
||||
def test_pageurl_with_invalid_page(self):
|
||||
tpl = template.Template(
|
||||
"""{% load wagtailcore_tags %}<a href="{% pageurl page %}">Events</a>"""
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
tpl.render(template.Context({"page": 123}))
|
||||
|
||||
|
||||
class TestWagtailSiteTag(TestCase):
|
||||
fixtures = ["test.json"]
|
||||
|
|
Ładowanie…
Reference in New Issue