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


Python EmailUserCreationForm.clean_username方法代码示例

本文整理汇总了Python中cards.forms.EmailUserCreationForm.clean_username方法的典型用法代码示例。如果您正苦于以下问题:Python EmailUserCreationForm.clean_username方法的具体用法?Python EmailUserCreationForm.clean_username怎么用?Python EmailUserCreationForm.clean_username使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cards.forms.EmailUserCreationForm的用法示例。


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

示例1: FormTestCase

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
class FormTestCase(TestCase):
    def setUp(self):
        # Create a player so that this username we're testing is already taken
        self.player = Player.objects.create_user(username='test-user')
        self.form_same_username = EmailUserCreationForm()
        self.form_diff_username = EmailUserCreationForm()

    def test_clean_username_exception(self):
        # set up the form for testing
        self.form_same_username.cleaned_data = {'username': 'test-user'}
        self.form_diff_username.cleaned_data = {'username': 'mike'}
        # use a context manager to watch for the validation error being raised
        with self.assertRaises(ValidationError):
            self.form_same_username.clean_username()
        # asserts clean username is the same as
        self.assertEqual(self.form_diff_username.clean_username(), 'mike')

    def test_register_sends_email(self):
        self.form_diff_username.cleaned_data = {
            'username': 'test',
            'email': '[email protected]',
            'password1': 'test-pw',
            'password2': 'test-pw',
        }
        self.form_diff_username.save()
        # Check there is an email to send
        self.assertEqual(len(mail.outbox), 1)
        # Check the subject is what we expect
        self.assertEqual(mail.outbox[0].subject, 'Welcome!')
开发者ID:mlee284045,项目名称:playing-cards,代码行数:31,代码来源:test_form.py

示例2: test_clean_username_exception

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
    def test_clean_username_exception(self):
        Player.objects.create_user(username='test-user')
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        with self.assertRaises(ValidationError):
            form.clean_username()
开发者ID:broccolirob,项目名称:deck,代码行数:9,代码来源:test_forms.py

示例3: test_clean_username_exception

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
 def test_clean_username_exception(self):
     # Create a player so that this username we're testing is already taken
     Player.objects.create_user(username='test-user')
     # set up the form for testing
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     # use a context manager to watch for the validation error being raised
     with self.assertRaises(ValidationError):
         form.clean_username()
开发者ID:michaelperret,项目名称:playing-cards,代码行数:11,代码来源:tests.py

示例4: test_clean_username

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
    def test_clean_username(self):
        form = EmailUserCreationForm()
        form.cleaned_data = {
            'username': 'test-user',
        }

        self.assertTrue(form.clean_username() == 'test-user')
开发者ID:broccolirob,项目名称:deck,代码行数:9,代码来源:test_forms.py

示例5: test_clean_username

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
    def test_clean_username(self):
        # review this again!
        # set up the form for testing
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        # use a context manager to watch for the validation error being raised
        self.assertEquals(form.clean_username(), 'test-user')
开发者ID:masterfung,项目名称:RocketU-Django,代码行数:10,代码来源:tests.py

示例6: test_clean_username_ok

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
 def test_clean_username_ok(self):
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     self.assertEqual(form.clean_username(), 'test-user')
开发者ID:armenarmen,项目名称:playing-cards,代码行数:6,代码来源:tests.py

示例7: test_clean_username

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
 def test_clean_username(self):
     # set up the form for testing
     form = EmailUserCreationForm()
     form.cleaned_data = {'username': 'test-user'}
     self.assertEquals(form.clean_username(), 'test-user')
开发者ID:brittkistner,项目名称:playing_cards,代码行数:7,代码来源:test_forms.py

示例8: test_clean_username_success

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
    def test_clean_username_success(self):
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'testie'}

        # watch for the correct output
        self.assertEqual(form.clean_username(), 'testie')
开发者ID:michaelperret,项目名称:playing-cards,代码行数:8,代码来源:tests.py

示例9: test_clean_username_pass

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
 def test_clean_username_pass(self):
     Player.objects.create_user(username='bla')
     form = EmailUserCreationForm()
     form.cleaned_data = {'username':'test'}
     self.assertEqual(form.clean_username(), 'test')
开发者ID:kevintandean,项目名称:playing-cards,代码行数:7,代码来源:test.py

示例10: test_clean_username_success

# 需要导入模块: from cards.forms import EmailUserCreationForm [as 别名]
# 或者: from cards.forms.EmailUserCreationForm import clean_username [as 别名]
    def test_clean_username_success(self):
        """Test that we get the proper result from username not already taken"""
        form = EmailUserCreationForm()
        form.cleaned_data = {'username': 'test-user'}

        self.assertEqual(form.clean_username(), 'test-user')
开发者ID:kremerben,项目名称:playing-cards,代码行数:8,代码来源:tests.py


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