def test_signal(self, handler): post = Post.objects.create( title='signal post', slug='signal-post', ) handler.assert_called_once() self.assertTrue(handler.return_value) handler.reset_mock() post.title = 'mod title' post.save() handler.assert_called_once() self.assertTrue(handler.return_value) handler.reset_mock() with pause_knocks(post): post.title = 'pause title' post.save() self.assertFalse(active_knocks(post)) handler.assert_not_called() post.title = 'mod title' post.save() handler.assert_called_once() self.assertTrue(handler.return_value) handler.reset_mock()
def test_admin_clear_menu(self): """ Tests that after changing apphook config menu structure the menu content is different: new value is taken immediately into account """ pages = self.get_pages() post = self._get_post(self._post_data[0]['en']) request = self.get_page_request(None, self.user, r'/en/page-two/') first_nodes = menu_pool.get_nodes(request) with pause_knocks(post): with self.login_user_context(self.user): data = dict(namespace='sample_app', app_title='app1', object_name='Blog') data['config-menu_structure'] = MENU_TYPE_NONE data['config-sitemap_changefreq'] = 'weekly' data['config-sitemap_priority'] = '0.5' request = self.post_request(pages[0], 'en', user=self.user, data=data) msg_mid = MessageMiddleware() msg_mid.process_request(request) config_admin = admin.site._registry[BlogConfig] response = config_admin.change_view(request, str(self.app_config_1.pk)) second_nodes = menu_pool.get_nodes(request) self.assertNotEqual(len(first_nodes), len(second_nodes))
def test_admin_post_text(self): pages = self.get_pages() post = self._get_post(self._post_data[0]['en']) with pause_knocks(post): with self.login_user_context(self.user): with self.settings(BLOG_USE_PLACEHOLDER=False): data = {'post_text': 'ehi text', 'title': 'some title'} request = self.post_request(pages[0], 'en', user=self.user, data=data, path='/en/?edit_fields=post_text') msg_mid = MessageMiddleware() msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.edit_field(request, post.pk, 'en') self.assertEqual(response.status_code, 200) modified_post = Post.objects.language('en').get(pk=post.pk) self.assertEqual(modified_post.safe_translation_getter('post_text'), data['post_text'])
def test_admin_post_text(self): pages = self.get_pages() post = self._get_post(self._post_data[0]['en']) with pause_knocks(post): with self.login_user_context(self.user): with self.settings(BLOG_USE_PLACEHOLDER=False): data = {'post_text': 'ehi text', 'title': 'some title'} request = self.post_request( pages[0], 'en', user=self.user, data=data, path='/en/?edit_fields=post_text') msg_mid = MessageMiddleware() msg_mid.process_request(request) post_admin = admin.site._registry[Post] response = post_admin.edit_field(request, post.pk, 'en') self.assertEqual(response.status_code, 200) modified_post = Post.objects.language('en').get(pk=post.pk) self.assertEqual( modified_post.safe_translation_getter('post_text'), data['post_text'])