Viewing file: atom.mock_http.html (20.99 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
Python: module atom.mock_http
# 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.
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 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)
|
|
Data |
| |
__author__ = 'api.jscudder (Jeff Scudder)' |
Author |
| |
api.jscudder (Jeff Scudder) |
|