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='newusername', email='new2@test.test', password='example', confirm='example', invite_code="code1")
        assert form.validate() is False
        assert 'Invite Code has already been used.' in form.invite_code.errors
dataset/ETHPy150Open codeforamerica/comport/tests/test_user_forms.py/TestRegisterForm.test_validate_invite_code_used_already/original