summaryrefslogtreecommitdiffstats
path: root/tests/test_pages.py
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2016-03-06 15:00:53 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2016-03-20 09:47:46 (GMT)
commit6abb1b30c04170ce936692724d7fba605914e68e (patch)
tree0a8923581869dce0d3f674220f33038eb0eb1c7b /tests/test_pages.py
parente674108beea2697099ae3b4d2675fc84c558d046 (diff)
downloadcombo-6abb1b30c04170ce936692724d7fba605914e68e.zip
combo-6abb1b30c04170ce936692724d7fba605914e68e.tar.gz
combo-6abb1b30c04170ce936692724d7fba605914e68e.tar.bz2
general: fix site import when link cells refer to future cells (#8598)
Diffstat (limited to 'tests/test_pages.py')
-rw-r--r--tests/test_pages.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/test_pages.py b/tests/test_pages.py
index 79aadcc..1e55973 100644
--- a/tests/test_pages.py
+++ b/tests/test_pages.py
@@ -1,7 +1,7 @@
import pytest
from django.contrib.auth.models import User, Group
-from combo.data.models import Page
+from combo.data.models import Page, CellBase, TextCell, LinkCell
pytestmark = pytest.mark.django_db
@@ -112,3 +112,52 @@ def test_page_visibility():
assert not page.is_visible()
assert page.is_visible(user1)
assert not page.is_visible(user2)
+
+def test_import_export_pages():
+ page = Page(title='foo', slug='foo', order=0)
+ page.save()
+
+ cell = TextCell(page=page, text='foo', order=0)
+ cell.save()
+
+ page2 = Page(title='bar', slug='bar', order=1, parent=page)
+ page2.save()
+
+ cell = TextCell(page=page2, text='bar', order=0)
+ cell.save()
+
+ site_export = [x.get_serialized_page() for x in Page.objects.all()]
+ Page.objects.all().delete()
+
+ Page.load_serialized_pages(site_export)
+
+ new_page_1 = Page.objects.all().order_by('order')[0]
+ new_page_2 = Page.objects.all().order_by('order')[1]
+ assert new_page_1.title == 'foo'
+ assert new_page_2.title == 'bar'
+ assert len(CellBase.get_cells(page_id=new_page_1.id)) == 1
+ assert isinstance(CellBase.get_cells(page_id=new_page_1.id)[0], TextCell)
+ assert CellBase.get_cells(page_id=new_page_1.id)[0].text == 'foo'
+
+def test_import_export_pages_with_links():
+ page = Page(title='foo', slug='foo', order=0)
+ page.save()
+
+ page2 = Page(title='bar', slug='bar', order=1)
+ page2.save()
+
+ cell = LinkCell(page=page, title='bar', link_page=page2, order=1)
+ cell.save()
+
+ cell2 = LinkCell(page=page2, title='foo', link_page=page, order=1)
+ cell2.save()
+
+ site_export = [x.get_serialized_page() for x in Page.objects.all()]
+ Page.objects.all().delete()
+
+ Page.load_serialized_pages(site_export)
+
+ new_page_1 = Page.objects.all().order_by('order')[0]
+ new_page_2 = Page.objects.all().order_by('order')[1]
+ assert CellBase.get_cells(page_id=new_page_1.id)[0].link_page_id == new_page_2.id
+ assert CellBase.get_cells(page_id=new_page_2.id)[0].link_page_id == new_page_1.id