def test_form_succeeds_with_valid_values(self, user_get_mock): form = UserRegistrationForm({ 'email': '*****@*****.**', 'password1': 'abc', 'password2': 'abc', }) eq_(form.is_valid(), True) user_get_mock.assert_called_once_with(email__iexact='*****@*****.**')
def test_form_with_different_passwords_fails(self): form = UserRegistrationForm({ 'email': '*****@*****.**', 'password1': 'alpha', 'password2': 'omega', }) eq_(form.is_valid(), False) ok_(form.non_field_errors())
def test_form_with_registered_email_fails(self, user_get_mock): form = UserRegistrationForm({ 'email': '*****@*****.**', 'password1': 'abc', 'password2': 'abc', }) eq_(form.is_valid(), False) ok_('email' in form.errors) user_get_mock.assert_called_once_with(email__iexact='*****@*****.**')
def test_form_with_empty_fields_fails(self): form = UserRegistrationForm({ 'email': '', 'password1': '', 'password2': '', }) eq_(form.is_valid(), False) ok_('email' in form.errors) ok_('password1' in form.errors) ok_('password2' in form.errors)
def test_empty_form_fails(self): form = UserRegistrationForm({}) eq_(form.is_valid(), False) ok_('email' in form.errors) ok_('password1' in form.errors) ok_('password2' in form.errors)