test_plugins.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:cmsplugin-form-handler 作者: mkoistinen 项目源码 文件源码
def test_form_submission_without_sessions(self):
        """
        Test that a (normal, non-Crispy) form submission results in an
        additional Sample instance.
        """
        # Disable session MW
        MW = list(settings.MIDDLEWARE_CLASSES)
        MW.remove('django.contrib.sessions.middleware.SessionMiddleware')

        with override_settings(MiddleWare=MW):
            # First get the number Sample-instances
            current_samples = Sample.objects.count()

            sample_name = self.get_random_string(10)
            sample_msg = self.get_random_string(100)

            action_url = reverse(
                'cmsplugin_form_handler:process_form',
                args=(self.model_form_plugin.pk, )
            )

            response = self.client.post(action_url, {
                'name': sample_name,
                'message': sample_msg,
                'cmsplugin_form_source_url': '/en/',
            }, follow=True)
            self.assertEqual(response.status_code, 200)
            assert Sample.objects.count() > current_samples
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号