def set_up(self): transport = transports.XmlRpcTransport( endpoint_url='http://endpoint-url', ) self.env.client = SoftLayer.BaseClient( transport=transport, auth=auth.BasicAuthentication('username', 'api-key'))
def set_up(self): super(TestHelpSetup, self).set_up() # NOTE(kmcdonald): since the endpoint_url is changed with the client # in these commands, we need to ensure that a fixtured transport is # used. transport = testing.MockableTransport(SoftLayer.FixtureTransport()) self.env.client = SoftLayer.BaseClient(transport=transport)
def __init__(self, client=None, timeout=5): if client is None: transport = transports.RestTransport( timeout=timeout, endpoint_url=consts.API_PRIVATE_ENDPOINT_REST, ) client = SoftLayer.BaseClient(transport=transport) self.client = client
def test_verify_request_false(self): client = SoftLayer.BaseClient(transport=self.mocks) mock = self.set_mock('SoftLayer_SERVICE', 'METHOD') mock.return_value = {"test": "result"} resp = client.call('SERVICE', 'METHOD', verify=False) self.assertEqual(resp, {"test": "result"}) self.assert_called_with('SoftLayer_SERVICE', 'METHOD', verify=False)
def setUp(self): # NOQA testtools.TestCase.setUp(self) self.mocks.clear() transport = SoftLayer.XmlRpcTransport(endpoint_url=self.endpoint_url) wrapped_transport = SoftLayer.TimingTransport(transport) self.client = SoftLayer.BaseClient(transport=wrapped_transport) self.env = environment.Environment() self.env.client = self.client self.set_up()
def cli(env, format='table', config=None, debug=0, verbose=0, proxy=None, really=False, fixtures=False, **kwargs): """Main click CLI entry-point.""" # Set logging level if debug is not None: verbose = int(debug) if verbose: logger = logging.getLogger() logger.addHandler(logging.StreamHandler()) logger.setLevel(DEBUG_LOGGING_MAP.get(verbose, logging.DEBUG)) # Populate environement with client and set it as the context object env.skip_confirmations = really env.config_file = config env.format = format if env.client is None: # Environment can be passed in explicitly. This is used for testing if fixtures: client = SoftLayer.BaseClient( transport=SoftLayer.FixtureTransport(), auth=None, ) else: # Create SL Client client = SoftLayer.create_client_from_env( proxy=proxy, config_file=config, ) env.client = client env.vars['timings'] = SoftLayer.TimingTransport(env.client.transport) env.client.transport = env.vars['timings']
def ensure_client(self, config_file=None, is_demo=False, proxy=None): """Create a new SLAPI client to the environment. This will be a no-op if there is already a client in this environment. """ if self.client is not None: return # Environment can be passed in explicitly. This is used for testing if is_demo: client = SoftLayer.BaseClient( transport=SoftLayer.FixtureTransport(), auth=None, ) else: # Create SL Client client = SoftLayer.create_client_from_env( proxy=proxy, config_file=config_file, ) self.client = client