Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
 def test_form_valid_data(self):
     form = RegistrationForm(
         data={
             'email': '*****@*****.**',
             'username': '******',
             'password': '******',
             'confirm_password': '******',
         })
     self.assertTrue(form.validate())
Esempio n. 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)
Esempio n. 5
0
 def test_form_no_data(self):
     form = RegistrationForm(data={})
     self.assertFalse(form.validate())
     self.assertEquals(len(form.errors), 4)