def clean(self): if self.cleaned_data.get('is_shibboleth_login_required'): try: Institution.is_valid_email_address( self.cleaned_data.get('email')) except InvalidInstitutionalEmailAddress as e: raise forms.ValidationError(str(e))
def clean(self): cleaned_data = super().clean() is_shibboleth_login_required = cleaned_data.get( 'is_shibboleth_login_required') email = cleaned_data.get('email') if is_shibboleth_login_required: try: Institution.is_valid_email_address(email) except InvalidInstitution as e: raise forms.ValidationError(str(e))
def test_invalid_institutional_email_address(self): with self.assertRaises(InvalidInstitutionalEmailAddress) as e: Institution.is_valid_email_address('*****@*****.**') self.assertEqual(str(e.exception), 'Email address domain is not supported.')
def test_valid_institutional_email_address(self): self.assertTrue( Institution.is_valid_email_address('*****@*****.**'))