Esempio n. 1
0
    def test_valid(self):
        email = "*****@*****.**"

        form = EmailUserCreationForm(
            {'email': email,
             'password1': 'password',
             'password2': 'password'})
        self.assertTrue(form.is_valid())
Esempio n. 2
0
    def test_valid(self):
        email = "*****@*****.**"

        form = EmailUserCreationForm({
            'email': email,
            'password1': 'password',
            'password2': 'password'
        })
        self.assertTrue(form.is_valid())
Esempio n. 3
0
    def test_email_not_valid(self):
        email = "user.example.com"

        form = EmailUserCreationForm(
            {'email': email,
             'password1': 'password',
             'password2': 'password'})
        self.assertFalse(form.is_valid())
        self.assertIn('email', form.errors)
Esempio n. 4
0
    def test_email_not_valid(self):
        email = "user.example.com"

        form = EmailUserCreationForm({
            'email': email,
            'password1': 'password',
            'password2': 'password'
        })
        self.assertFalse(form.is_valid())
        self.assertIn('email', form.errors)
Esempio n. 5
0
    def test_user_exists(self):
        email = "*****@*****.**"
        EmailUserFactory(email=email)

        form = EmailUserCreationForm(
            {'email': email,
             'password1': 'password',
             'password2': 'password'})
        self.assertFalse(form.is_valid())
        self.assertIn('email', form.errors)
Esempio n. 6
0
    def test_password_too_short(self):
        email = "*****@*****.**"

        form = EmailUserCreationForm(
            {'email': email,
             'password1': 'passw',
             'password2': 'passw'})
        self.assertFalse(form.is_valid())
        self.assertIn('password1', form.errors)
        self.assertIn('password2', form.errors)
Esempio n. 7
0
    def test_user_exists(self):
        email = "*****@*****.**"
        EmailUserFactory(email=email)

        form = EmailUserCreationForm({
            'email': email,
            'password1': 'password',
            'password2': 'password'
        })
        self.assertFalse(form.is_valid())
        self.assertIn('email', form.errors)
Esempio n. 8
0
    def test_password_too_short(self):
        email = "*****@*****.**"

        form = EmailUserCreationForm({
            'email': email,
            'password1': 'passw',
            'password2': 'passw'
        })
        self.assertFalse(form.is_valid())
        self.assertIn('password1', form.errors)
        self.assertIn('password2', form.errors)
Esempio n. 9
0
    def validate(self, attrs):
        attrs = super().validate(attrs)

        email = attrs.get('email')
        password = attrs.get('password')

        form = EmailUserCreationForm(data={
            'email': email,
            'password1': password,
            'password2': password,
            })
        if not form.is_valid():
            raise exceptions.ValidationError(form.errors)
        return attrs
Esempio n. 10
0
    def validate(self, attrs):
        attrs = super().validate(attrs)

        email = attrs.get('email')
        password = attrs.get('password')

        form = EmailUserCreationForm(data={
            'email': email,
            'password1': password,
            'password2': password,
        })
        if not form.is_valid():
            raise exceptions.ValidationError(form.errors)
        return attrs