7
This repository has been archived on 2023-05-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
cavemanon-wagtail-personali…/tests/unit/test_utils.py
tm-kn a47803eca5 Delete related variants when deleting the segment (#183)
* Delete related variants when deleting the segment

Closes #155

* Fix typo

* Fix migration ordering

* Split metadata migrations
2018-07-19 12:59:46 +02:00

39 lines
1.0 KiB
Python

import pytest
from tests.factories.page import ContentPageFactory
from wagtail_personalisation.utils import (
can_delete_pages, impersonate_other_page)
@pytest.fixture
def rootpage():
return ContentPageFactory(parent=None, path='/', depth=0, title='root')
@pytest.fixture
def page(rootpage):
return ContentPageFactory(parent=rootpage, path='/hi', title='Hi')
@pytest.fixture
def otherpage(rootpage):
return ContentPageFactory(parent=rootpage, path='/bye', title='Bye')
@pytest.mark.django_db
def test_impersonate_other_page(page, otherpage):
impersonate_other_page(page, otherpage)
assert page.title == otherpage.title == 'Bye'
assert page.path == otherpage.path
@pytest.mark.django_db
def test_can_delete_pages_with_superuser(rf, user, segmented_page):
user.is_superuser = True
assert can_delete_pages([segmented_page], user)
@pytest.mark.django_db
def test_cannot_delete_pages_with_standard_user(user, segmented_page):
assert not can_delete_pages([segmented_page], user)