atom.mock_http | index /usr/local/google/home/afshar/src/external-gdata-release/google3/src/atom/mock_http.py

`# Copyright (C) 2008 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.`

Modules

``

atom |  |  |

Classes

``

__builtin__.object
  MockRequest
atom.http_interface.GenericHttpClient(__builtin__.object)
  MockHttpClient
atom.http_interface.HttpResponse(__builtin__.object)
  MockResponse
exceptions.Exception(exceptions.BaseException)
  Error
    NoRecordingFound

class Error(exceptions.Exception)

``

Method resolution order:
  Error
  exceptions.Exception
  exceptions.BaseException
  __builtin__.object

Data descriptors defined here:

__weakref__
  `list of weak references to the object (if defined)`

Methods inherited from exceptions.Exception:

__init__(...)
  `x.__init__(...) initializes x; see help(type(x)) for signature`

Data and other attributes inherited from exceptions.Exception:

__new__ = <built-in method __new__ of type object>
  `T.__new__(S, ...) -> a new object with type S, a subtype of T`

Methods inherited from exceptions.BaseException:

__delattr__(...)
  `x.__delattr__('name') <==> del x.name`

__getattribute__(...)
  `x.__getattribute__('name') <==> x.name`

__getitem__(...)
  `x.__getitem__(y) <==> x[y]`

__getslice__(...)
  `x.__getslice__(i, j) <==> x[i:j]
  Use of negative indices is not supported.`

__reduce__(...)

__repr__(...)
  `x.__repr__() <==> repr(x)`

__setattr__(...)
  `x.__setattr__('name', value) <==> x.name = value`

__setstate__(...)

__str__(...)
  `x.__str__() <==> str(x)`

__unicode__(...)

Data descriptors inherited from exceptions.BaseException:

__dict__

args

message

class MockHttpClient(atom.http_interface.GenericHttpClient)

``

Method resolution order:
  MockHttpClient
  atom.http_interface.GenericHttpClient
  __builtin__.object

Methods defined here:

__init__(self, headers=None, recordings=None, real_client=None)
  `An HttpClient which responds to request with stored data.
  The request-response pairs are stored as tuples in a member list named
  recordings.
  The MockHttpClient can be switched from replay mode to record mode by
  setting the real_client member to an instance of an HttpClient which will
  make real HTTP requests and store the server's response in list of
  recordings.
  Args:
  headers: dict containing HTTP headers which should be included in all
  HTTP requests.
  recordings: The initial recordings to be used for responses. This list
  contains tuples in the form: (MockRequest, MockResponse)
  real_client: An HttpClient which will make a real HTTP request. The
  response will be converted into a MockResponse and stored in
  recordings.`

add_response(self, response, operation, url, data=None, headers=None)
  `Adds a request-response pair to the recordings list.
  After the recording is added, future matching requests will receive the
  response.
  Args:
  response: MockResponse
  operation: str
  url: str
  data: str, Currently the data is ignored when looking for matching
  requests.
  headers: dict of strings: Currently the headers are ignored when
  looking for matching requests.`

request(self, operation, url, data=None, headers=None)
  `Returns a matching MockResponse from the recordings.
  If the real_client is set, the request will be passed along and the
  server's response will be added to the recordings and also returned.
  If there is no match, a NoRecordingFound error will be raised.`

Methods inherited from atom.http_interface.GenericHttpClient:

delete(self, url, headers=None)

get(self, url, headers=None)

post(self, url, data, headers=None)

put(self, url, data, headers=None)

Data descriptors inherited from atom.http_interface.GenericHttpClient:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

Data and other attributes inherited from atom.http_interface.GenericHttpClient:

debug = False

class MockRequest(__builtin__.object)
`` | `Holds parameters of an HTTP request for matching against future requests.`

Methods defined here:

__init__(self, operation, url, data=None, headers=None)

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

class MockResponse(atom.http_interface.HttpResponse)
`` | `Simulates an httplib.HTTPResponse object.`

Method resolution order:
  MockResponse
  atom.http_interface.HttpResponse
  __builtin__.object

Methods defined here:

__init__(self, body=None, status=None, reason=None, headers=None)

read(self)

Methods inherited from atom.http_interface.HttpResponse:

getheader(self, name, default=None)

Data descriptors inherited from atom.http_interface.HttpResponse:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

class NoRecordingFound(Error)

``

Method resolution order:
  NoRecordingFound
  Error
  exceptions.Exception
  exceptions.BaseException
  __builtin__.object

Data descriptors inherited from Error:

__weakref__
  `list of weak references to the object (if defined)`

Methods inherited from exceptions.Exception:

__init__(...)
  `x.__init__(...) initializes x; see help(type(x)) for signature`

Data and other attributes inherited from exceptions.Exception:

__new__ = <built-in method __new__ of type object>
  `T.__new__(S, ...) -> a new object with type S, a subtype of T`

Methods inherited from exceptions.BaseException:

__delattr__(...)
  `x.__delattr__('name') <==> del x.name`

__getattribute__(...)
  `x.__getattribute__('name') <==> x.name`

__getitem__(...)
  `x.__getitem__(y) <==> x[y]`

__getslice__(...)
  `x.__getslice__(i, j) <==> x[i:j]
  Use of negative indices is not supported.`

__reduce__(...)

__repr__(...)
  `x.__repr__() <==> repr(x)`

__setattr__(...)
  `x.__setattr__('name', value) <==> x.name = value`

__setstate__(...)

__str__(...)
  `x.__str__() <==> str(x)`

__unicode__(...)

Data descriptors inherited from exceptions.BaseException:

__dict__

args

message

Data
`` |  | __author__ = 'api.jscudder (Jeff Scudder)'

Author
`` |  | api.jscudder (Jeff Scudder)