l.t.MockHttp(BaseMockHttpObject) : class documentation

Part of libcloud.test View Source View In Hierarchy

Known subclasses: libcloud.test.compute.test_bluebox.BlueboxMockHttp, libcloud.test.compute.test_brightbox.BrightboxMockHttp, libcloud.test.compute.test_cloudsigma.CloudSigmaHttp, libcloud.test.compute.test_deployment.RackspaceMockHttp, libcloud.test.compute.test_dreamhost.DreamhostMockHttp, libcloud.test.compute.test_ec2.EC2MockHttp, libcloud.test.compute.test_ecp.ECPMockHttp, libcloud.test.compute.test_elasticstack.ElasticStackMockHttp, libcloud.test.compute.test_gandi.GandiMockHttp, libcloud.test.compute.test_gogrid.GoGridMockHttp, libcloud.test.compute.test_gridspot.GridspotMockHttp, libcloud.test.compute.test_ibm_sce.IBMMockHttp, libcloud.test.compute.test_joyent.JoyentHttp, libcloud.test.compute.test_linode.LinodeMockHttp, libcloud.test.compute.test_opennebula.OpenNebula_1_4_MockHttp, libcloud.test.compute.test_opennebula.OpenNebula_2_0_MockHttp, libcloud.test.compute.test_opsource.OpsourceMockHttp, libcloud.test.compute.test_rimuhosting.RimuHostingMockHttp, libcloud.test.compute.test_slicehost.SlicehostMockHttp, libcloud.test.compute.test_softlayer.SoftLayerMockHttp, libcloud.test.compute.test_vcl.VCLMockHttp, libcloud.test.compute.test_vcloud.TerremarkMockHttp, libcloud.test.compute.test_vcloud.VCloud_1_5_MockHttp, libcloud.test.compute.test_voxel.VoxelMockHttp, libcloud.test.compute.test_vpsnet.VPSNetMockHttp, libcloud.test.dns.test_linode.LinodeMockHttp, libcloud.test.dns.test_rackspace.RackspaceMockHttp, libcloud.test.dns.test_zerigo.ZerigoMockHttp, libcloud.test.MockHttpTestCase, libcloud.test.StorageMockHttp

A mock HTTP client/server suitable for testing purposes. This replaces
`HTTPConnection` by implementing its API and returning a mock response.

Define methods by request path, replacing slashes (/) with underscores (_).
Each of these mock methods should return a tuple of:

    (int status, str body, dict headers, str reason)

>>> mock = MockHttp('localhost', 8080)
>>> mock.request('GET', '/example/')
>>> response = mock.getresponse()
>>> response.body.read()
'Hello World!'
>>> response.status
200
>>> response.getheaders()
[('X-Foo', 'libcloud')]
>>> MockHttp.type = 'fail'
>>> mock.request('GET', '/example/')
>>> response = mock.getresponse()
>>> response.body.read()
'Oh Noes!'
>>> response.status
403
>>> response.getheaders()
[('X-Foo', 'fail')]
Method __init__ Undocumented
Method request Undocumented
Method getresponse Undocumented
Method connect Can't think of anything to mock here.
Method close Undocumented
Method _example Return a simple message and header, regardless of input.
Method _example_fail Undocumented

Inherited from BaseMockHttpObject:

Method _get_method_name Undocumented
def __init__(self, host, port, *args, **kwargs): (source)
Undocumented
def request(self, method, url, body=None, headers=None, raw=False): (source)
Undocumented
def getresponse(self): (source)
Undocumented
def connect(self): (source)
Can't think of anything to mock here.
def close(self): (source)
Undocumented
def _example(self, method, url, body, headers): (source)
Return a simple message and header, regardless of input.
def _example_fail(self, method, url, body, headers): (source)
Undocumented
API Documentation for libcloud, generated by pydoctor at 2012-11-19 12:09:27.