def testIsGCEServerNotFound(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndRaise(
        httplib2.ServerNotFoundError)

    self.mox.ReplayAll()
    self.assertFalse(oauth2_client._IsGCE())

    self.mox.VerifyAll()
  def testIsGCETrue(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndReturn((
        FakeResponse(200), ''))

    self.mox.ReplayAll()
    self.assertTrue(oauth2_client._IsGCE())

    self.mox.VerifyAll()
Exemple #3
0
  def testIsGCETrue(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndReturn((
        FakeResponse(200), ''))

    self.mox.ReplayAll()
    self.assertTrue(oauth2_client._IsGCE())

    self.mox.VerifyAll()
  def testIsGCENotFound(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndReturn((
        FakeResponse(404), ''))

    self.mox.ReplayAll()
    self.assertFalse(oauth2_client._IsGCE())

    self.mox.VerifyAll()
Exemple #5
0
  def testIsGCEServerNotFound(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndRaise(
        httplib2.ServerNotFoundError)

    self.mox.ReplayAll()
    self.assertFalse(oauth2_client._IsGCE())

    self.mox.VerifyAll()
Exemple #6
0
  def testIsGCENotFound(self):
    self.mock_http.request(oauth2_client.METADATA_SERVER).AndReturn((
        FakeResponse(404), ''))

    self.mox.ReplayAll()
    self.assertFalse(oauth2_client._IsGCE())

    self.mox.VerifyAll()
Exemple #7
0
  def testIsGCETrue(self):
    self.mock_http.request.return_value = (FakeResponse(200), '')

    self.assertTrue(oauth2_client._IsGCE())
    self.mock_http.request.assert_called_once_with(
        oauth2_client.METADATA_SERVER)
Exemple #8
0
  def testIsGCEServerNotFound(self):
    self.mock_http.request.side_effect = httplib2.ServerNotFoundError()

    self.assertFalse(oauth2_client._IsGCE())
    self.mock_http.request.assert_called_once_with(
        oauth2_client.METADATA_SERVER)
Exemple #9
0
  def testIsGCENotFound(self):
    self.mock_http.request.return_value = (FakeResponse(404), '')

    self.assertFalse(oauth2_client._IsGCE())
    self.mock_http.request.assert_called_once_with(
        oauth2_client.METADATA_SERVER)