Beispiel #1
0
 def test_retries_errors_with_exponential_delay_when_building_client(self):
   self.build.side_effect = [
       HttpError(mock.Mock(), 'error'),
       HttpError(mock.Mock(), 'error'),
       HttpError(mock.Mock(), 'error'),
       'client'
   ]
   self.assertEquals(endpoints.build_client('foo', 'bar', 'baz'), 'client')
   self.sleep.assert_has_calls([mock.call(1), mock.call(2), mock.call(4)])
Beispiel #2
0
  def __init__(self, project_name):
    self.project_name = project_name

    app_id = app_identity.get_application_id()
    if app_id.endswith('-staging'):
      discovery_url = DISCOVERY_URL % '-staging'
    else:
      discovery_url = DISCOVERY_URL % '-prod'

    self.client = endpoints.build_client('monorail', 'v1', discovery_url)
Beispiel #3
0
  def __init__(self, project_name, use_staging=False):
    self.project_name = project_name

    if use_staging:
      discovery_url = DISCOVERY_URL % '-staging'
    else:
      discovery_url = DISCOVERY_URL % '-prod'

    self.client = endpoints.build_client(
        'monorail', 'v1', discovery_url, http=httplib2.Http(timeout=60))
Beispiel #4
0
    def __init__(self, use_staging=False):
        if use_staging:
            discovery_url = DISCOVERY_URL % '-staging'
        else:
            discovery_url = DISCOVERY_URL % ''

        self.client = endpoints.build_client('findit',
                                             'v1',
                                             discovery_url,
                                             http=httplib2.Http(timeout=60))
Beispiel #5
0
    def __init__(self):
        app_id = app_identity.get_application_id()
        if app_id.endswith('-staging'):
            discovery_url = DISCOVERY_URL % '-staging'
        else:
            discovery_url = DISCOVERY_URL % ''

        self.client = endpoints.build_client('findit',
                                             'v1',
                                             discovery_url,
                                             http=httplib2.Http(timeout=60))
Beispiel #6
0
 def test_uses_provided_http(self):
   self.cred.return_value.authorize = mock.Mock()
   endpoints.build_client('foo', 'bar', 'baz', http='myhttp')
   self.cred.return_value.authorize.assert_called_once_with('myhttp')
Beispiel #7
0
 def test_fails_to_build_client_after_5_errors(self):
   self.build.side_effect = [HttpError(mock.Mock(), 'error')] * 3
   with self.assertRaises(HttpError):
     endpoints.build_client('foo', 'bar', 'baz', num_tries=3)