Permalink
Browse files

Merge pull request #2167 from yakky/feature/test_1881_30

Port of the test for multiple site publishing to 3.0
  • Loading branch information...
2 parents 11ec2ad + a6f9e13 commit c895cf201c4e609fc4ec9b54d00d91317b3ad6d2 @yakky yakky committed Aug 17, 2013
Showing with 58 additions and 4 deletions.
  1. +3 −3 cms/test_utils/cli.py
  2. +55 −1 cms/tests/site.py
View
@@ -146,7 +146,7 @@ def configure(db_url, **extra):
{
'code': 'de',
'name': gettext('German'),
- 'fallbacks': ['fr', 'en'],
+ 'fallbacks': ['fr'],
'public': True,
},
{
@@ -159,13 +159,13 @@ def configure(db_url, **extra):
{
'code': 'nl',
'name': gettext('Dutch'),
- 'fallbacks': ['fr', 'en'],
+ 'fallbacks': ['de'],
'public': True,
},
{
'code': 'de',
'name': gettext('German'),
- 'fallbacks': ['fr', 'en'],
+ 'fallbacks': ['nl'],
'public': False,
},
],
View
@@ -1,7 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
+import copy
+from django.test import Client
from cms.api import create_page
from cms.models import Page
+from cms.utils import get_cms_setting
+from cms.views import details
from cms.test_utils.testcases import CMSTestCase
from cms.test_utils.util.context_managers import SettingsOverride
from django.contrib.auth.models import User
@@ -30,7 +34,6 @@ def setUp(self):
def tearDown(self):
self._login_context.__exit__(None, None, None)
-
def test_site_framework(self):
#Test the site framework, and test if it's possible to disable it
with SettingsOverride(SITE_ID=self.site2.pk):
@@ -53,4 +56,55 @@ def test_site_framework(self):
# without param
self.assertEqual(Page.objects.drafts().on_site().count(), 1)
+ def test_site_publish(self):
+ self._login_context.__exit__(None, None, None)
+ pages = {"2": list(range(0, 5)), "3": list(range(0, 5))}
+ lang_settings = copy.deepcopy(get_cms_setting('LANGUAGES'))
+ lang_settings[3][1]['public'] = True
+
+ with SettingsOverride(CMS_LANGUAGES=lang_settings, LANGUAGE_CODE="de"):
+ with SettingsOverride(SITE_ID=self.site2.pk):
+ pages["2"][0] = create_page("page_2", "nav_playground.html", "de",
+ site=self.site2)
+ pages["2"][0].publish()
+ pages["2"][1] = create_page("page_2_1", "nav_playground.html", "de",
+ parent=pages["2"][0], site=self.site2)
+ pages["2"][2] = create_page("page_2_2", "nav_playground.html", "de",
+ parent=pages["2"][0], site=self.site2)
+ pages["2"][3] = create_page("page_2_1_1", "nav_playground.html", "de",
+ parent=pages["2"][1], site=self.site2)
+ pages["2"][4] = create_page("page_2_1_2", "nav_playground.html", "de",
+ parent=pages["2"][1], site=self.site2)
+
+ for page in pages["2"]:
+ page.publish()
+ for page in pages["2"]:
+ if page.is_home():
+ page_url = "/de/"
+ else:
+ page_url = page.get_absolute_url(language='de')
+ response = self.client.get(page_url)
+ self.assertEqual(response.status_code, 200)
+
+ with SettingsOverride(SITE_ID=self.site3.pk):
+ pages["3"][0] = create_page("page_3", "nav_playground.html", "de",
+ site=self.site3)
+ pages["3"][0].publish()
+ pages["3"][1] = create_page("page_3_1", "nav_playground.html", "de",
+ parent=pages["3"][0], site=self.site3)
+ pages["3"][2] = create_page("page_3_2", "nav_playground.html", "de",
+ parent=pages["3"][0], site=self.site3)
+ pages["3"][3] = create_page("page_3_1_1", "nav_playground.html", "de",
+ parent=pages["3"][1], site=self.site3)
+ pages["3"][4] = create_page("page_3_1_2", "nav_playground.html", "de",
+ parent=pages["3"][1], site=self.site3)
+ for page in pages["3"]:
+ page.publish()
+ for page in pages["3"]:
+ if page.is_home():
+ page_url = "/de/"
+ else:
+ page_url = page.get_absolute_url(language='de')
+ response = self.client.get(page_url)
+ self.assertEqual(response.status_code, 200)

0 comments on commit c895cf2

Please sign in to comment.