def test_invoke_with_no_credentials(self): # This is what happens you have no credentials. # get_credentials() return None. self.session.get_credentials.return_value = None caller = CLIOperationCaller(self.session) with self.assertRaises(NoCredentialsError): caller.invoke(None, None, None)
def display_response(session, operation_name, result, parsed_globals): if result is not None: cli_operation_caller = CLIOperationCaller(session) # Calling a private method. Should be changed after the functionality # is moved outside CliOperationCaller. cli_operation_caller._display_response(operation_name, result, parsed_globals)
def display_response(session, operation_name, result, parsed_globals): if result is not None: cli_operation_caller = CLIOperationCaller(session) # Calling a private method. Should be changed after the functionality # is moved outside CliOperationCaller. cli_operation_caller._display_response( operation_name, result, parsed_globals)
def test_invoke_with_page_size(self): operation_object = mock.Mock() paginate = operation_object.paginate operation_object.can_paginate = True parsed_globals = mock.Mock() parsed_globals.paginate = True parsed_globals.page_size = '10' parameters = {} caller = CLIOperationCaller(self.session) with mock.patch('awscli.clidriver.CLIOperationCaller._display_response'): caller.invoke(operation_object, parameters, parsed_globals) self.assertEqual(paginate.call_args[1], {'page_size': u'10'})
def test_invoke_with_no_page_size(self): operation_object = mock.Mock() paginate = operation_object.paginate operation_object.can_paginate = True parsed_globals = mock.Mock() parsed_globals.paginate = True parsed_globals.page_size = None parameters = {} caller = CLIOperationCaller(self.session) with mock.patch('awscli.clidriver.CLIOperationCaller._display_response'): caller.invoke(operation_object, parameters, parsed_globals) # No parameters were passed to it (i.e. only self and endpoint). self.assertEqual(len(paginate.call_args), 2)
def test_invoke_with_page_size(self): operation_object = mock.Mock() paginate = operation_object.paginate operation_object.can_paginate = True parsed_globals = mock.Mock() parsed_globals.paginate = True parsed_globals.page_size = '10' parameters = {} caller = CLIOperationCaller(self.session) with mock.patch( 'awscli.clidriver.CLIOperationCaller._display_response'): caller.invoke(operation_object, parameters, parsed_globals) self.assertEqual(paginate.call_args[1], {'page_size': u'10'})
def test_invoke_with_no_page_size(self): operation_object = mock.Mock() paginate = operation_object.paginate operation_object.can_paginate = True parsed_globals = mock.Mock() parsed_globals.paginate = True parsed_globals.page_size = None parameters = {} caller = CLIOperationCaller(self.session) with mock.patch( 'awscli.clidriver.CLIOperationCaller._display_response'): caller.invoke(operation_object, parameters, parsed_globals) # No parameters were passed to it (i.e. only self and endpoint). self.assertEqual(len(paginate.call_args), 2)
def _building_command_table(command_table, session, **kwargs): # Hooked up to building-command-table.rds # We don't need the modify-option-group operation. del command_table['modify-option-group'] # We're going to replace modify-option-group with two commands: # add-option-group and remove-option-group rds_model = session.get_service_model('rds') modify_operation_model = rds_model.operation_model('ModifyOptionGroup') command_table['add-option-to-option-group'] = ServiceOperation( parent_name='rds', name='add-option-to-option-group', operation_caller=CLIOperationCaller(session), session=session, operation_model=modify_operation_model) command_table['remove-option-from-option-group'] = ServiceOperation( parent_name='rds', name='remove-option-from-option-group', session=session, operation_model=modify_operation_model, operation_caller=CLIOperationCaller(session))
def call_and_display_response(session, operation_name, parameters, parsed_globals): cli_operation_caller = CLIOperationCaller(session) cli_operation_caller.invoke( 'emr', operation_name, parameters, parsed_globals)
def call_and_display_response(session, operation_name, parameters, parsed_globals): cli_operation_caller = CLIOperationCaller(session) cli_operation_caller.invoke( session.get_service('emr').get_operation(operation_name), parameters, parsed_globals)
def call_and_display_response(session, operation_name, parameters, parsed_globals): cli_operation_caller = CLIOperationCaller(session) cli_operation_caller.invoke("emr", operation_name, parameters, parsed_globals)