def test_blank_data(self, db): form = RegistrationForm({}) required = ['This field is required.'] assert not form.is_valid() assert form.errors == { 'name': required, 'email': required, 'password': required, 'password_confirm': required, }
def test_valid_data(self, db): form = RegistrationForm({ 'name': "Turanga Leela", 'email': "*****@*****.**", 'password': "******", 'password_confirm': 'pass123' }) assert form.is_valid() registered_user = form.save() assert registered_user.name == "Turanga Leela" assert registered_user.email == "*****@*****.**"
def test_not_matching_passwords(self, db): form = RegistrationForm({ 'name': "Turanga Leela", 'email': "*****@*****.**", 'password': "******", 'password_confirm': 'wrong123' }) assert form.errors == { 'password_confirm': ['Passwords do not match'], } assert not form.is_valid()