示例#1
0
    def test_form_not_valid_username(self):
        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)
示例#2
0
    def test_form_not_valid_password(self):
        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 2)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 2)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)

        form = RegistrationForm(
            data={
                'email': '*****@*****.**',
                'username': '******',
                'password': '******',
                'confirm_password': '******',
            })
        self.assertFalse(form.validate())
        self.assertEquals(len(form.errors), 1)
示例#3
0
 def test_form_valid_data(self):
     form = RegistrationForm(
         data={
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******',
         })
     self.assertTrue(form.validate())
示例#4
0
 def test_user_already_existss(self):
     # User exists
     form = RegistrationForm(
         data={
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******',
         })
     self.assertFalse(form.validate())
     self.assertEquals(len(form.errors), 1)
示例#5
0
 def test_form_no_data(self):
     form = RegistrationForm(data={})
     self.assertFalse(form.validate())
     self.assertEquals(len(form.errors), 4)