'Test that a page can be created
and that a new language can be created afterwards in the admin pages'

def test_create_page(self):

    current_site = Site.objects.get_current()
    TESTLANG = get_primary_language(current_site=current_site)
    page_data = self.get_new_page_data_dbfields(site=current_site, language=TESTLANG)
    page = create_page(**page_data)
    title = page.get_title_obj()
    self.assertNotEqual(title, None)
    page.publish(TESTLANG)
    page.unpublish(TESTLANG)
    page = page.reload()
    self.assertEqual(page.get_title(), page_data['title'])
    self.assertEqual(page.get_slug(), page_data['slug'])
    self.assertEqual(page.placeholders.all().count(), 2)
    title = Title.objects.drafts().get(slug=page_data['slug'])
    self.assertEqual(title.language, TESTLANG)
    superuser = self.get_superuser()
    with self.login_user_context(superuser):
        page_data = self.get_pagedata_from_dbfields(page_data)
        page_data['published'] = True
        self.client.post((URL_CMS_PAGE_CHANGE_LANGUAGE % (page.pk, TESTLANG)), page_data)
        self.client.post((URL_CMS_PAGE_PUBLISH % (page.pk, TESTLANG)))
        page = page.reload()
        self.assertTrue(page.is_published(TESTLANG))
        page_data2 = page_data.copy()
        page_data2['title'] = 'ein    Titel'
        page_data2['slug'] = 'ein-slug'
        TESTLANG2 = get_secondary_language(current_site=current_site)
        page_data2['language'] = TESTLANG2
        self.assertTrue(isinstance(page.get_title_obj(language=TESTLANG2, fallback=False), EmptyTitle))
        self.client.post((URL_CMS_PAGE_CHANGE_LANGUAGE % (page.pk, TESTLANG2)), page_data2)
        page = page.reload()
        self.assertEqual(page.get_title(language=TESTLANG2), page_data2['title'])
        self.assertEqual(page.get_slug(language=TESTLANG2), page_data2['slug'])
        self.assertEqual(page.get_slug(language=TESTLANG, fallback=False), page_data['slug'])
        self.assertEqual(page.get_title(language=TESTLANG, fallback=False), page_data['title'])
        self.assertEqual(page.get_slug(fallback=False), page_data['slug'])
        self.assertEqual(page.get_title(fallback=False), page_data['title'])
