Author: batiste.bieler
Date: Mon Jan 26 08:20:26 2009
New Revision: 320
Modified:
trunk/pages/tests.py
Log:
Add a test for slug collision
Modified: trunk/pages/tests.py
==============================================================================
--- trunk/pages/tests.py (original)
+++ trunk/pages/tests.py Mon Jan 26 08:20:26 2009
@@ -1,11 +1,14 @@
from django.test import TestCase
-
+import settings
from pages.models import *
from django.test.client import Client
+page_data = {'title':'test
page', 'slug':'test-page', 'language':'en', 'sites':[1], 'status':1}
+
class PagesTestCase(TestCase):
fixtures = ['tests.json']
+
def test_01_add_page(self):
"""
Test that the add admin page could be displayed via the admin
@@ -22,6 +25,31 @@
"""
c = Client()
c.login(username= 'batiste', password='b')
- page_data = {'title':'test
page', 'slug':'test-page', 'language':'en', 'sites':[1], 'status':1}
response = c.post('/admin/pages/page/add/', page_data)
self.assertRedirects(response, '/admin/pages/page/')
+ slug_content = Content.objects.get_page_slug(page_data['slug'])
+ assert(slug_content is not None)
+ page = slug_content.page
+ assert(page.title() == page_data['title'])
+ assert(page.slug() == page_data['slug'])
+
+ def test_03_slug_collision(self):
+ """
+ Test a slug collision
+ """
+ c = Client()
+ c.login(username= 'batiste', password='b')
+ response = c.post('/admin/pages/page/add/', page_data)
+ self.assertRedirects(response, '/admin/pages/page/')
+ page1 = Content.objects.get_page_slug(page_data['slug']).page
+
+ response = c.post('/admin/pages/page/add/', page_data)
+ assert(response.status_code == 200)
+
+ settings.PAGE_UNIQUE_SLUG_REQUIRED = False
+ response = c.post('/admin/pages/page/add/', page_data)
+ self.assertRedirects(response, '/admin/pages/page/')
+ page2 = Content.objects.get_page_slug(page_data['slug']).page
+ assert(page1.id != page2.id)
+
+
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---