def prepare_discovery_request(self, response_body):
   self._response = test_utils.MockConnectionResponse(200, response_body)
   discovery = discovery_service.DiscoveryService(
       self.api_config_manager)
   discovery._discovery_proxy = self.mox.CreateMock(
       discovery_api_proxy.DiscoveryApiProxy)
   return discovery
    def prepare_discovery_request(self, status_code, body):
        self.mox.StubOutWithMock(http.client.HTTPSConnection, 'request')
        self.mox.StubOutWithMock(http.client.HTTPSConnection, 'getresponse')
        self.mox.StubOutWithMock(http.client.HTTPSConnection, 'close')

        http.client.HTTPSConnection.request(mox.IsA(str), mox.IsA(str),
                                            mox.IgnoreArg(), mox.IsA(dict))
        http.client.HTTPSConnection.getresponse().AndReturn(
            test_utils.MockConnectionResponse(status_code, body))
        http.client.HTTPSConnection.close()
 def test_generate_discovery_doc_invalid_format(self):
     self._response = test_utils.MockConnectionResponse(400, 'Error')
     self.assertRaises(ValueError,
                       self.discovery_api.generate_discovery_doc,
                       self.api_config_dict, 'blah')