当前位置: 首页>>代码示例>>Python>>正文


Python forms.CourseEmailTemplateForm类代码示例

本文整理汇总了Python中bulk_email.forms.CourseEmailTemplateForm的典型用法代码示例。如果您正苦于以下问题:Python CourseEmailTemplateForm类的具体用法?Python CourseEmailTemplateForm怎么用?Python CourseEmailTemplateForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CourseEmailTemplateForm类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_missing_message_body_in_plain

 def test_missing_message_body_in_plain(self):
     """
     Asserts that we fail validation if we do not have the {{message_body}} tag
     in the submitted plain template
     """
     form_data = {"html_template": "{{message_body}}", "plain_template": "", "name": ""}
     form = CourseEmailTemplateForm(form_data)
     self.assertFalse(form.is_valid())
开发者ID:geekmooc,项目名称:edx-platform,代码行数:8,代码来源:test_forms.py

示例2: test_missing_message_body_in_html

 def test_missing_message_body_in_html(self):
     """
     Asserts that we fail validation if we do not have the {{message_body}} tag
     in the submitted HTML template
     """
     form_data = {
         'html_template': '',
         'plain_template': '{{message_body}}',
         'name': ''
     }
     form = CourseEmailTemplateForm(form_data)
     self.assertFalse(form.is_valid())
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:12,代码来源:test_forms.py

示例3: test_non_blank_name

    def test_non_blank_name(self):
        """
        Asserts that submitting a CourseEmailTemplateForm with a non-blank name
        can be found in the database under than name as a look-up key
        """
        form_data = {"html_template": "{{message_body}}", "plain_template": "{{message_body}}", "name": "foo"}
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        # now inspect the database and make sure the blank name was stored as a NULL
        # Note this will throw an exception if it is not found
        cet = CourseEmailTemplate.objects.get(name="foo")
        self.assertIsNotNone(cet)
开发者ID:geekmooc,项目名称:edx-platform,代码行数:14,代码来源:test_forms.py

示例4: test_name_with_spaces_is_trimmed

    def test_name_with_spaces_is_trimmed(self):
        """
        Asserts that submitting a CourseEmailTemplateForm with a name that contains
        whitespace at the beginning or end of a name is stripped
        """
        form_data = {"html_template": "{{message_body}}", "plain_template": "{{message_body}}", "name": " foo  "}
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        # now inspect the database and make sure the name is properly
        # stripped
        cet = CourseEmailTemplate.objects.get(name="foo")
        self.assertIsNotNone(cet)
开发者ID:geekmooc,项目名称:edx-platform,代码行数:14,代码来源:test_forms.py

示例5: test_name_with_only_spaces_is_null

    def test_name_with_only_spaces_is_null(self):
        """
        Asserts that submitting a CourseEmailTemplateForm just blank whitespace is stored
        as a NULL in the database
        """
        form_data = {"html_template": "{{message_body}}", "plain_template": "{{message_body}}", "name": "   "}
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        # now inspect the database and make sure the whitespace only name was stored as a NULL
        # Note this will throw an exception if it is not found
        cet = CourseEmailTemplate.objects.get(name=None)
        self.assertIsNotNone(cet)
开发者ID:geekmooc,项目名称:edx-platform,代码行数:14,代码来源:test_forms.py

示例6: test_blank_name_is_null

    def test_blank_name_is_null(self):
        """
        Asserts that submitting a CourseEmailTemplateForm with a blank name is stored
        as a NULL in the database
        """
        form_data = {
            'html_template': '{{message_body}}',
            'plain_template': '{{message_body}}',
            'name': ''
        }
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        # now inspect the database and make sure the blank name was stored as a NULL
        # Note this will throw an exception if it is not found
        cet = CourseEmailTemplate.objects.get(name=None)
        self.assertIsNotNone(cet)
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:18,代码来源:test_forms.py

示例7: test_duplicate_name

    def test_duplicate_name(self):
        """
        Assert that we cannot submit a CourseEmailTemplateForm with a name
        that already exists
        """

        # first set up one template
        form_data = {
            'html_template': '{{message_body}}',
            'plain_template': '{{message_body}}',
            'name': 'foo'
        }
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        # try to submit form with the same name
        form = CourseEmailTemplateForm(form_data)
        self.assertFalse(form.is_valid())

        # try again with a name with extra whitespace
        # this should fail as we strip the whitespace away
        form_data = {
            'html_template': '{{message_body}}',
            'plain_template': '{{message_body}}',
            'name': '  foo '
        }
        form = CourseEmailTemplateForm(form_data)
        self.assertFalse(form.is_valid())

        # then try a different name
        form_data = {
            'html_template': '{{message_body}}',
            'plain_template': '{{message_body}}',
            'name': 'bar'
        }
        form = CourseEmailTemplateForm(form_data)
        self.assertTrue(form.is_valid())
        form.save()

        form = CourseEmailTemplateForm(form_data)
        self.assertFalse(form.is_valid())
开发者ID:Lektorium-LLC,项目名称:edx-platform,代码行数:42,代码来源:test_forms.py


注:本文中的bulk_email.forms.CourseEmailTemplateForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。