def MockDoOAuthAuth(self, user=None, is_admin=None, fail=False):
    """Mock calling auth.DoOAuthAuth().

    Args:
      user: user for DoOAuthAuth to return.
      fail: bool, whether to fail or not
    """
    if not 'authDoOAuthAuth' in self._set_mock:
      self.mox.StubOutWithMock(auth, 'DoOAuthAuth')
      self._set_mock['authDoOAuthAuth'] = 1
    if fail:
      if is_admin is None:
        auth.DoOAuthAuth().AndRaise(auth.NotAuthenticated)
      else:
        auth.DoOAuthAuth(is_admin=is_admin).AndRaise(auth.NotAuthenticated)
    else:
      if is_admin is None:
        auth.DoOAuthAuth().AndReturn(user)
      else:
        auth.DoOAuthAuth(is_admin=is_admin).AndReturn(user)
dataset/ETHPy150Open google/simian/src/tests/simian/mac/common/test.py/RequestHandlerTest.MockDoOAuthAuth/original