def test_edit_page_other_site_and_language(self):
"""
Test that a page can edited via the admin when your current site is
different from the site you are editing and the language isn't available
for the current site.
"""
self.assertEqual(Site.objects.all().count(), 1)
site = Site.objects.create(domain='otherlang', name='otherlang', pk=2)
# Change site for this session
page_data = self.get_new_page_data()
page_data['site'] = site.pk
page_data['title'] = 'changed title'
self.assertEqual(site.pk, 2)
TESTLANG = get_cms_setting('LANGUAGES')[site.pk][0]['code']
page_data['language'] = TESTLANG
superuser = self.get_superuser()
with self.login_user_context(superuser):
response = self.client.post(URL_CMS_PAGE_ADD, page_data)
self.assertRedirects(response, URL_CMS_PAGE)
page = Page.objects.get(title_set__slug=page_data['slug'], publisher_is_draft=True)
with LanguageOverride(TESTLANG):
self.assertEqual(page.get_title(), 'changed title')
评论列表
文章目录