Esempio n. 1
0
 def test_clean_username_exception(self):
     User.objects.create_user(username='******')
     form = RegistrationForm()
     form.cleaned_data = {'username': '******'}
     # Use a context manager to watch for the validation error being raised
     with self.assertRaises(ValidationError):
         form.clean_username()
Esempio n. 2
0
File: tests.py Progetto: roxna/rad
 def test_clean_username_exception(self):
     User.objects.create_user(username='******')
     form = RegistrationForm()
     form.cleaned_data = {'username': '******'}
     # Use a context manager to watch for the validation error being raised
     with self.assertRaises(ValidationError):
         form.clean_username()
Esempio n. 3
0
def register(request):
    form = RegistrationForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            new_user = authenticate(username=request.POST['username'],
                                    password=request.POST['password1'])
            login(request, new_user)
            return redirect('/dashboard')
    data = {'form': form}
    return render(request, "registration/register.html", data)
Esempio n. 4
0
File: views.py Progetto: roxna/rad
def register(request):
    form = RegistrationForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            new_user = authenticate(username=request.POST['username'],
                                    password=request.POST['password1'])
            login(request, new_user)
            return redirect('/dashboard')
    data = {
        'form': form
    }
    return render(request, "registration/register.html", data)
Esempio n. 5
0
 def test_clean_username(self):
     form = RegistrationForm()
     form.cleaned_data = {'username': '******'}
     self.assertEqual(form.cleaned_data['username'], 'test-user')
Esempio n. 6
0
File: tests.py Progetto: roxna/rad
 def test_clean_username(self):
     form = RegistrationForm()
     form.cleaned_data = {'username': '******'}
     self.assertEqual(form.cleaned_data['username'], 'test-user')