Exemple #1
0
def signup(request):
    context = {}
    if request.POST:
        try:
            register_user(request.POST)
            return redirect('accounts:login')
        except ValidationError as e:
            context = {'errors': e}
    return render(request,
                  template_name='accounts/signup.html',
                  context=context)
Exemple #2
0
    def test_user_signup_success(self):
        signup_data = {
            'email': '*****@*****.**',
            'password1': 'hellothere_1',
            'password2': 'hellothere_1',
            'first_name': 'test_name',
            'middle_name': 'test_second_name',
            'last_name': 'test_last_name',
            'phone_number': '38102300123',
            'city': 'Київ',
            'region': 'Київська',
            'study': 'study school for test',
        }

        services.register_user(signup_data)

        with connection.cursor() as cursor:
            cursor.execute(f"SELECT * FROM contesttest.participant "
                           ""
                           f"WHERE email='{signup_data['email']}'")
            data = cursor.fetchall()
        self.assertEqual(len(data), 1)
Exemple #3
0
 def test_user_signup_fail_password_simple(self):
     signup_data = self.signup_data
     signup_data['password1'] = '12345'
     signup_data['password2'] = '12345'
     with self.assertRaises(ValidationError):
         services.register_user(signup_data)
Exemple #4
0
 def test_user_signup_fail_passwords_different(self):
     signup_data = self.signup_data
     signup_data['password1'] = 'abaklsdkasd'
     signup_data['password2'] = 'aklsdkaslkdasld'
     with self.assertRaises(ValidationError, msg="Passwords are different"):
         services.register_user(signup_data)
Exemple #5
0
 def test_user_signup_fail_email(self):
     signup_data = self.signup_data
     signup_data['email'] = '123@g'
     with self.assertRaises(ValidationError):
         services.register_user(signup_data)