def test_get_user_by_email(self): # check if exception rises for the wrong data type with self.assertRaises(TypeException) as _ex: UserHandler.get_user_by_email(1) self.assertEqual("email parameter type must be string!", str(_ex.exception)) # check if email validation is called UserHandler._email_validation = self.factory.email_validation UserHandler.get_user_by_email('email') self.factory.email_validation.assert_called() # check if session and query is called UserHandler._email_validation = self.factory.email_validation UserHandler.get_user_by_email('email') self.factory.session.assert_called() self.factory.session().query.assert_called()
def test_get_user_by_email_should_not_return_password(self): UserHandler._email_validation = self.factory.email_validation u = UserHandler.get_user_by_email('email') self.assertIsNone(u.password)