def test_registration(self): """ register """ form_data = {'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass'} form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), True)
def test_registration_honeypot(self): """ registration honeypot """ form_data = {'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass', 'honeypot': 'im a robot'} form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), False) self.assertNotIn('honeypot', form.cleaned_data)
def test_registration_invalid(self): """ invalid email and user """ User.objects.create_user(username="******", password="******", email="*****@*****.**") form_data = {'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass'} form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), False) self.assertNotIn('username', form.cleaned_data) self.assertNotIn('*****@*****.**', form.cleaned_data)
def test_registration(self): """ register """ form_data = { 'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass' } form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), True)
def test_registration_honeypot(self): """ registration honeypot """ form_data = { 'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass', 'honeypot': 'im a robot' } form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), False) self.assertNotIn('honeypot', form.cleaned_data)
def test_registration_invalid(self): """ invalid email and user """ User.objects.create_user(username="******", password="******", email="*****@*****.**") form_data = { 'username': '******', 'email': '*****@*****.**', 'password1': 'pass', 'password2': 'pass' } form = RegistrationForm(data=form_data) self.assertEqual(form.is_valid(), False) self.assertNotIn('username', form.cleaned_data) self.assertNotIn('*****@*****.**', form.cleaned_data)