Part of libcloud.test View Source View In Hierarchy
Known subclasses: libcloud.test.common.test_gandi.BaseGandiMockHttp, 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_ecp.ECPMockHttp, libcloud.test.compute.test_elasticstack.ElasticStackMockHttp, libcloud.test.compute.test_gogrid.GoGridMockHttp, libcloud.test.compute.test_gridspot.GridspotMockHttp, libcloud.test.compute.test_hostvirtual.HostVirtualMockHttp, 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_hostvirtual.HostVirtualMockHttp, libcloud.test.dns.test_linode.LinodeMockHttp, libcloud.test.dns.test_rackspace.RackspaceMockHttp, libcloud.test.dns.test_route53.Route53MockHttp, 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 |
Return a simple message and header, regardless of input.