Esempio n. 1
0
    def test_email_shortcut_function(self):
        with patch('bdea.client.urlopen') as urlopen_mock:
            res = self.RESPONSE.copy()
            urlopen_mock.return_value = StringIO('{}'.format(json.dumps(res)))
            assert is_disposable_email('*****@*****.**', 'apikey') == False

            res.update({
                'domain_status': 'block'
            })
            urlopen_mock.return_value = StringIO('{}'.format(json.dumps(res)))
            assert is_disposable_email('*****@*****.**', 'apikey') == True
def disposable_email_validator(email):
    """Disposable email validator."""
    apikey = settings.BDEA_APIKEY
    if is_disposable_email(email, apikey):
        raise ValidationError(
            _('Temporary or disposable email addresses are not allowed'))
def disposable_email_validator(email):
    """Disposable email validator."""
    apikey = settings.BDEA_APIKEY
    if is_disposable_email(email, apikey):
        raise ValidationError(_('Temporary or disposable email addresses are not allowed'))