def test_not_email(self): """Assert an IntegrityError without the email key results in a 500 error""" err = IntegrityError('SQL Statement', {}, None) msg, errno = app.integrity_error_handler(err) self.assertEqual(500, errno) self.assertEqual('The server encountered an unexpected error', msg)
def test_not_email(self): """Assert an IntegrityError without the email key results in a 500 error""" err = IntegrityError("SQL Statement", {}, None) msg, errno = app.integrity_error_handler(err) self.assertEqual(500, errno) self.assertEqual("The server encountered an unexpected error", msg)
def test_email(self): """Assert an HTTP 400 is generated from an email IntegrityError.""" err = IntegrityError('SQL Statement', {'email': '*****@*****.**'}, None) expected_msg = ( "Error: There's already an account associated with your email, " "authenticate with Demo Provider.") msg, errno = app.integrity_error_handler(err) self.assertEqual(400, errno) self.assertEqual(expected_msg, msg)
def test_no_social_auth(self): """Assert an HTTP 500 is generated from an social_auth IntegrityError.""" err = IntegrityError("SQL Statement", {"email": "*****@*****.**"}, None) expected_msg = ( "Error: There was already an existing account with missing provider. " "So we removed it. " "Please try to log in again." ) msg, errno = app.integrity_error_handler(err) self.assertEqual(500, errno) self.assertEqual(expected_msg, msg)
def test_no_social_auth(self): """Assert an HTTP 500 is generated from an social_auth IntegrityError.""" err = IntegrityError('SQL Statement', {'email': '*****@*****.**'}, None) expected_msg = ( "Error: There was already an existing account with missing provider. " "So we removed it. " "Please try to log in again.") msg, errno = app.integrity_error_handler(err) self.assertEqual(500, errno) self.assertEqual(expected_msg, msg)
def test_no_social_auth(self): """Assert an HTTP 400 is generated from an social_auth IntegrityError.""" err = IntegrityError('SQL Statement', { 'social_auth': 'user', 'email': '*****@*****.**' }, None) expected_msg = ( "Error: Authentication with authentication provider failed. " "Please try again later...") msg, errno = app.integrity_error_handler(err) self.assertEqual(500, errno) self.assertEqual(expected_msg, msg)
def test_email(self): """Assert an HTTP 400 is generated from an email IntegrityError.""" social_auth_user = social_models.UserSocialAuth( provider='Demo Provider', user=self.user) self.session.add(social_auth_user) self.session.commit() err = IntegrityError('SQL Statement', {'email': '*****@*****.**'}, None) expected_msg = ( "Error: There's already an account associated with your email, " "authenticate with Demo Provider.") msg, errno = app.integrity_error_handler(err) self.assertEqual(400, errno) self.assertEqual(expected_msg, msg)
def test_email(self): """Assert an HTTP 400 is generated from an email IntegrityError.""" social_auth_user = social_models.UserSocialAuth( provider="Demo Provider", user=self.user ) self.session.add(social_auth_user) self.session.commit() err = IntegrityError("SQL Statement", {"email": "*****@*****.**"}, None) expected_msg = ( "Error: There's already an account associated with your email, " "authenticate with Demo Provider." ) msg, errno = app.integrity_error_handler(err) self.assertEqual(400, errno) self.assertEqual(expected_msg, msg)