def test_validate_user_already_registered(self, user): # Enters username that is already registered form = RegisterForm(username=user.username, email='*****@*****.**', password='******', confirm='example', invite_code="bad") assert form.validate() is False assert 'Username already registered' in form.username.errors
def test_validate_email_already_registered(self, user): # enters email that is already registered form = RegisterForm(username='******', email=user.email, password='******', confirm='example', invite_code="bad") assert form.validate() is False assert 'Email already registered' in form.email.errors
def test_validate_invite_code_used_already(self, user): department = Department.create(name="dept", short_name="DPD", load_defaults=False) Invite_Code.create(department_id=department.id, code="code1", used=True) form = RegisterForm(username='******', email='*****@*****.**', password='******', confirm='example', invite_code="code1") assert form.validate() is False assert 'Invite Code has already been used.' in form.invite_code.errors
def test_validate_success(self, db): department = Department.create(name="dept", load_defaults=False) Invite_Code.create(department_id=department.id, code="code") form = RegisterForm(username='******', email='*****@*****.**', password='******', confirm='example', invite_code="code") assert form.validate() is True
def test_validate_invite_code_valid(self, user): form = RegisterForm(username='******', email='*****@*****.**', password='******', confirm='example', invite_code="bad") assert form.validate() is False assert 'Invite Code not recognized.' in form.invite_code.errors
def test_validate_success(self, db): department = Department.create(name="dept", short_name="DPD", load_defaults=False) Invite_Code.create(department_id=department.id, code="code") form = RegisterForm(username='******', email='*****@*****.**', password='******', confirm='example', invite_code="code") assert form.validate() is True