Browse files

Fix testcase when PAGE_USE_SITE_ID is False by default.

  • Loading branch information...
1 parent f4b6336 commit 3138dacfafdb1e9d069d5c3de1c877f563df101a Batiste Bieler committed Nov 15, 2010
Showing with 54 additions and 33 deletions.
  1. +27 −14 pages/tests/test_functionnal.py
  2. +3 −3 pages/tests/test_unit.py
  3. +6 −5 pages/tests/testcase.py
  4. +2 −8 requirements/external_apps.txt
  5. +16 −3 setup.py
View
41 pages/tests/test_functionnal.py
@@ -78,25 +78,21 @@ def test_slug_collision(self):
page2 = Content.objects.get_content_slug_by_slug(page_data['slug']).page
self.assertNotEqual(page1.id, page2.id)
+
def test_details_view(self):
- """Test the details view."""
+ """Test the details view basics."""
c = self.get_admin_client()
- try:
- response = c.get(self.get_page_url())
- except TemplateDoesNotExist, e:
- if e.args != ('404.html',):
- raise
+ response = c.get(self.get_page_url())
+ self.assertEqual(response.status_code, 404)
page_data = self.get_new_page_data()
page_data['status'] = Page.DRAFT
response = c.post('/admin/pages/page/add/', page_data)
- try:
- response = c.get(self.get_page_url())
- except TemplateDoesNotExist, e:
- if e.args != ('404.html',):
- raise
+
+ response = c.get(self.get_page_url())
+ self.assertEqual(response.status_code, 200)
page_data = self.get_new_page_data()
page_data['status'] = Page.PUBLISHED
@@ -105,11 +101,12 @@ def test_details_view(self):
response = c.post('/admin/pages/page/add/', page_data)
self.assertRedirects(response, '/admin/pages/page/')
- response = c.get('/pages/test-page-2/')
+ response = c.get(self.get_page_url('test-page-2'))
self.assertEqual(response.status_code, 200)
+
def test_edit_page(self):
- """Test that a page can edited via the admin"""
+ """Test that a page can edited via the admin."""
c = self.get_admin_client()
c.login(username='batiste', password='b')
page_data = self.get_new_page_data()
@@ -127,9 +124,10 @@ def test_edit_page(self):
body = Content.objects.get_content(page, 'en-us', 'body')
self.assertEqual(body, 'changed body')
+
def test_site_framework(self):
"""Test the site framework, and test if it's possible to
- disable it"""
+ disable it."""
from pages import settings as pages_settings
@@ -195,6 +193,7 @@ def test_site_framework(self):
setattr(pages_settings, "SITE_ID", 1)
+
def test_languages(self):
"""Test post a page with different languages
and test that the admin views works correctly."""
@@ -262,6 +261,7 @@ def test_languages(self):
self.assertContains(response, 'french title')
self.assertContains(response, 'lang="fr-ch"')
+
def test_revision(self):
"""Test that a page can edited several times."""
c = self.get_admin_client()
@@ -289,6 +289,7 @@ def test_revision(self):
self.assertEqual(Content.objects.get_content(page, 'en-us', 'body'),
'changed body 2')
+
def test_placeholder(self):
"""
Test that the placeholder is correctly displayed in
@@ -305,6 +306,7 @@ def test_placeholder(self):
self.assertContains(response, 'name="right-column"', 1)
+
def test_directory_slug(self):
"""
Test diretory slugs
@@ -381,6 +383,7 @@ def test_page_admin_view(self):
response = c.get(url)
self.assertEqual(response.status_code, 302)
+
def test_page_alias(self):
"""Test page aliasing system"""
@@ -424,6 +427,7 @@ def test_page_alias(self):
self.assertRedirects(response,
self.get_page_url('downloads-page'), 301)
+
def test_page_redirect_to(self):
"""Test page redirected to an other page."""
@@ -440,6 +444,7 @@ def test_page_redirect_to(self):
response = client.get(page1.get_url_path())
self.assertRedirects(response, page2.get_url_path(), 301)
+
def test_page_valid_targets(self):
"""Test page valid_targets method"""
c = self.get_admin_client()
@@ -518,6 +523,7 @@ def test_ajax_language(self):
# Make sure the content response we got was in french
self.assertTrue('Auteur' in response.content)
+
def test_view_context(self):
"""
Test that the default view can only return the context
@@ -542,6 +548,7 @@ def test_request_mockup(self):
request = get_request_mock()
self.assertEqual(hasattr(request, 'session'), True)
+
def test_tree_admin_interface(self):
"""
Test that moving/creating page in the tree is working properly
@@ -623,6 +630,7 @@ def test_tree_admin_interface(self):
response = c.post('/admin/pages/page/%d/' % child_2.id, page_data)
self.assertEqual(response.status_code, 200)
+
def test_tree(self):
"""
Test that the navigation tree works properly with mptt.
@@ -687,6 +695,7 @@ def test_page_redirect_to_url(self):
self.assertTrue(response.status_code == 301)
self.assertTrue(response['Location'] == url)
+
def test_page_freeze_date(self):
"""Test page freezing feature."""
c = self.get_admin_client()
@@ -748,6 +757,7 @@ def test_delegate_to(self):
self.assertContains(response, "doc title 1")
reg.registry = []
+
def test_untranslated(self):
"""Test the untranslated feature in the admin."""
c = self.get_admin_client()
@@ -770,6 +780,7 @@ def test_untranslated(self):
response = c.get('/admin/pages/page/%d/?language=fr-ch' % page.id)
self.assertContains(response, unstranslated_string)
+
def test_root_page(self):
"""Test that the root page doesn't trigger a 404."""
c = self.get_admin_client()
@@ -781,6 +792,7 @@ def test_root_page(self):
response = c.get('/pages/')
self.assertEqual(response.status_code, 200)
+
def test_page_with_trailing_slash(self):
"""
Test that a page is also available with and without a trailing slash.
@@ -793,6 +805,7 @@ def test_page_with_trailing_slash(self):
response = c.get('/pages/other/')
self.assertEqual(response.status_code, 200)
+
def test_page_sitemap(self):
"""
Test the sitemap class
View
6 pages/tests/test_unit.py
@@ -413,8 +413,8 @@ def test_default_view_with_language_prefix(self):
req = get_request_mock()
self.assertRaises(Http404, details, req, '/pages/')
- page1 = self.new_page(content={'slug':'page1'})
- page2 = self.new_page(content={'slug':'page2'})
+ page1 = self.new_page(content={'slug': 'page1'})
+ page2 = self.new_page(content={'slug': 'page2'})
self.assertEqual(page1.get_url_path(), '/pages/en-us/page1')
@@ -439,7 +439,7 @@ def test_root_page_hidden_slug(self):
"""
Check that the root works properly in every case.
"""
- page1 = self.new_page(content={'slug':'page1'})
+ page1 = self.new_page(content={'slug': 'page1'})
self.set_setting("PAGE_USE_LANGUAGE_PREFIX", False)
self.set_setting("PAGE_HIDE_ROOT_SLUG", True)
self.assertEqual(page1.is_first_root(), True)
View
11 pages/tests/testcase.py
@@ -68,11 +68,11 @@ def reset_urlconf(self):
def get_new_page_data(self, draft=False):
"""Helper method for creating page datas"""
- page_data = {'title':'test page %d' % self.counter,
- 'slug':'test-page-%d' % self.counter, 'language':'en-us',
- 'sites':[1], 'status': Page.DRAFT if draft else Page.PUBLISHED,
+ page_data = {'title': 'test page %d' % self.counter,
+ 'slug': 'test-page-%d' % self.counter, 'language':'en-us',
+ 'sites': [1], 'status': Page.DRAFT if draft else Page.PUBLISHED,
# used to disable an error with connected models
- 'document_set-TOTAL_FORMS':0, 'document_set-INITIAL_FORMS':0,
+ 'document_set-TOTAL_FORMS': 0, 'document_set-INITIAL_FORMS': 0,
}
self.counter = self.counter + 1
return page_data
@@ -81,7 +81,8 @@ def new_page(self, content={'title':'test-page'}, language='en-us'):
author = User.objects.all()[0]
page = Page.objects.create(author=author, status=Page.PUBLISHED,
template='pages/examples/index.html')
- page.sites.add(Site.objects.get(id=1))
+ if pages_settings.PAGE_USE_SITE_ID:
+ page.sites.add(Site.objects.get(id=1))
# necessary to clear old URL cache
page.invalidate()
for key, value in content.items():
View
10 requirements/external_apps.txt
@@ -1,10 +1,4 @@
-setuptools
+django>=1.1.1
django-mptt>=0.4.1
-django-authority
html5lib>=0.10
-django>=1.1.1
-BeautifulSoup
-django-staticfiles
-django-haystack
-django-page-cms
-django-taggit
+BeautifulSoup
View
19 setup.py
@@ -1,13 +1,27 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
+from pkg_resources import require, DistributionNotFound
import pages
+import os
package_name = 'django-page-cms'
def local_open(fname):
return open(os.path.join(os.path.dirname(__file__), fname))
-import os
+requirements = local_open('requirements/external_apps.txt')
+
+# Build the list of dependency to install
+required_to_install = []
+for dist in requirements.readlines():
+ dist = dist.strip()
+ try:
+ print require(dist)
+ except DistributionNotFound:
+ required_to_install.append(dist)
+
+print required_to_install
+
data_dirs = []
for directory in os.walk('pages/templates'):
data_dirs.append(directory[0][6:] + '/*.*')
@@ -29,8 +43,7 @@ def local_open(fname):
license=pages.__license__,
long_description=local_open('README.rst').read(),
download_url=download_url,
- install_requires=[
- ],
+ install_requires=required_to_install,
packages=find_packages(exclude=['example', 'example.*']),
# very important for the binary distribution to include the templates.
package_data={'pages': data_dirs},

0 comments on commit 3138dac

Please sign in to comment.