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 setUp(self): # NOQA self.env = environment.Environment() # Create a crazy mockable, fixture client auth = SoftLayer.BasicAuthentication('default-user', 'default-key') self.mocks = MockableTransport(SoftLayer.FixtureTransport()) self.transport = SoftLayer.TimingTransport(self.mocks) self.client = SoftLayer.Client(transport=self.transport, auth=auth, timeout=10, endpoint_url='default-endpoint-url') self.env.client = self.client return 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
def cli(ctx, format='table', config=None, debug=0, verbose=0, proxy=None, really=False, fixtures=False, **kwargs): """Main click CLI entry-point.""" # Set logging level debug_int = int(debug) if debug_int: verbose = debug_int 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 = ctx.ensure_object(environment.Environment) 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: transport = SoftLayer.FixtureTransport() else: # Create SL Client transport = SoftLayer.XmlRpcTransport() wrapped_transport = SoftLayer.TimingTransport(transport) env.client = SoftLayer.Client(proxy=proxy, config_file=config, transport=wrapped_transport)
def setUpClass(cls): """Stand up fixtured/mockable XML-RPC server.""" cls.mocks = MockableTransport(SoftLayer.FixtureTransport()) cls.server = xmlrpc.create_test_server(cls.mocks) host, port = cls.server.socket.getsockname()[:2] cls.endpoint_url = "http://%s:%s" % (host, port)