'Test a slug collision'

def test_child_slug_collision(self):

    root = create_page('home', 'nav_playground.html', 'en', published=True)
    page = create_page('page', 'nav_playground.html', 'en')
    subPage = create_page('subpage', 'nav_playground.html', 'en', parent=page)
    create_page('child-page', 'nav_playground.html', 'en', parent=root)
    superuser = self.get_superuser()
    with self.login_user_context(superuser):
        response = self.client.get((URL_CMS_PAGE_ADD + ('?target=%s&position=right&site=1' % subPage.pk)))
        self.assertContains(response, ('value="%s"' % page.pk))
        page_data = self.get_new_page_data(page.pk)
        page_data['slug'] = 'subpage'
        response = self.client.post(URL_CMS_PAGE_ADD, page_data)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(response.request['PATH_INFO'].endswith(URL_CMS_PAGE_ADD))
        self.assertContains(response, '<ul    class="errorlist"><li>Another    page    with    this    slug    already    exists</li></ul>')
        page_data = self.get_new_page_data()
        page_data['slug'] = 'child-page'
        response = self.client.post(URL_CMS_PAGE_ADD, page_data)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(response.request['PATH_INFO'].endswith(URL_CMS_PAGE_ADD))
        self.assertContains(response, '<ul    class="errorlist"><li>Another    page    with    this    slug    already    exists</li></ul>')
        page_data = self.get_new_page_data()
        page_data['slug'] = 'page'
        response = self.client.post(URL_CMS_PAGE_ADD, page_data)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(response.request['PATH_INFO'].endswith(URL_CMS_PAGE_ADD))
        self.assertContains(response, '<ul    class="errorlist"><li>Another    page    with    this    slug    already    exists</li></ul>')
