7

Return 404 if variant page is accessed directly (#188)

This commit is contained in:
tm-kn
2018-09-25 06:57:06 +01:00
committed by Jasper Berghoef
parent 7d679d7111
commit d15f6c37d3
2 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,7 @@
import pytest
from django.http import Http404
from wagtail.core.models import Page
from tests.factories.segment import SegmentFactory
@ -16,6 +19,15 @@ def test_serve_variant_no_variant(site, rf):
assert result is None
@pytest.mark.django_db
def test_variant_accessed_directly_returns_404(segmented_page, rf):
request = rf.get('/')
args = tuple()
kwargs = {}
with pytest.raises(Http404):
wagtail_hooks.serve_variant(segmented_page, request, args, kwargs)
@pytest.mark.django_db
def test_serve_variant_with_variant_no_segment(site, rf, segmented_page):
request = rf.get('/')