def test_ask_for_customer_confirmation_to_delete_all_application_resources( self, validate_action_mock, echo_mock, get_environment_names_mock, describe_application_mock ): describe_application_mock.return_value = mock_responses.DESCRIBE_APPLICATIONS_RESPONSE['Applications'][0] get_environment_names_mock.return_value = Environment.json_to_environment_objects_array( mock_responses.DESCRIBE_ENVIRONMENTS_RESPONSE['Environments'] ) terminateops.ask_for_customer_confirmation_to_delete_all_application_resources( 'my-application' ) echo_mock.assert_called_once_with( """The application "my-application" and all its resources will be deleted. This application currently has the following: Running environments: 4 Configuration templates: 0 Application versions: 1 """ ) validate_action_mock.assert_called_once_with( 'To confirm, type the application name', 'my-application' )
def environment_from_mock_responses(environment_name): all_available_environments = Environment.json_to_environment_objects_array( mock_responses.DESCRIBE_ENVIRONMENTS_RESPONSE['Environments'] ) return [ environment for environment in all_available_environments if environment.name == environment_name ][0]
def test_clone__prompt_for_choice_between_current_and_latest_platform_arn_in_interactive_mode( self, prompt_for_item_in_list_mock, find_solution_stack_from_string_mock, is_cname_available_mock, get_app_name_mock, get_env_name_mock, make_cloned_env_mock, clone_environment_request_mock, prompt_for_environment_name_mock, get_environment_names_mock, get_environment_mock ): is_cname_available_mock.return_value = True find_solution_stack_from_string_mock.return_value = PlatformVersion( 'arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.2 running on 64bit Amazon Linux/2.6.5' ) get_app_name_mock.return_value = 'my-application' get_env_name_mock.return_value = 'environment-1' prompt_for_environment_name_mock.return_value = 'environment-1-clone' get_environment_names_mock.return_value = Environment.json_to_environment_objects_array( mock_responses.DESCRIBE_ENVIRONMENTS_RESPONSE['Environments'] ) get_environment_mock.return_value = environment_from_mock_responses('environment-1') prompt_for_item_in_list_mock.return_value = 'Latest (arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.2 running on 64bit Amazon Linux/2.6.5)' clone_environment_request_mock.return_value = mock.MagicMock() clone_environment_request = clone_environment_request_mock.return_value app = EB(argv=['clone', '--cname', 'some-cname']) app.setup() app.run() prompt_for_environment_name_mock.assert_called_once_with( default_name='my-application-clone', prompt_text='Enter name for Environment Clone' ) prompt_for_item_in_list_mock.assert_called_once_with( [ 'Latest (arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.2 running on 64bit Amazon Linux/2.6.5)', 'Same (arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.1 running on 64bit Amazon Linux/2.6.5)' ] ) clone_environment_request_mock.assert_called_once_with( app_name='environment-1', cname='some-cname', env_name='environment-1-clone', original_name='my-application', platform=PlatformVersion( 'arn:aws:elasticbeanstalk:us-west-2::platform/PHP 7.2 running on 64bit Amazon Linux/2.6.5' ), scale=None, tags=[] ) make_cloned_env_mock.assert_called_once_with( clone_environment_request, nohang=False, timeout=None )
def get_environments(env_names=None): LOG.debug('Inside get_environments api wrapper') result = _make_api_call('describe_environments', EnvironmentNames=env_names or [], IncludeDeleted=False) environments = result['Environments'] if not environments and env_names: raise NotFoundError( 'Could not find any environments from the list: {}'.format( ', '.join(env_names))) return Environment.json_to_environment_objects_array(environments)
def get_app_environments(app_name, include_deleted=False, deleted_back_to=None): LOG.debug('Inside get_app_environments api wrapper') kwargs = {} if include_deleted and deleted_back_to is not None: kwargs['IncludedDeletedBackTo'] = deleted_back_to result = _make_api_call('describe_environments', ApplicationName=app_name, IncludeDeleted=include_deleted, **kwargs) return Environment.json_to_environment_objects_array(result['Environments'])
def get_environments(env_names=None): LOG.debug('Inside get_environments api wrapper') result = _make_api_call('describe_environments', EnvironmentNames=env_names or [], IncludeDeleted=False) environments = result['Environments'] if not environments and env_names: raise NotFoundError( 'Could not find any environments from the list: {}'.format( ', '.join(env_names) ) ) return Environment.json_to_environment_objects_array(environments)
def test_clone__neither_clone_name_nor_cname_provided__customer_is_prompted_for_both( self, find_solution_stack_from_string_mock, is_cname_available_mock, get_app_name_mock, get_env_name_mock, make_cloned_env_mock, clone_environment_request_mock, get_cname_from_customer, prompt_for_environment_name_mock, get_environment_names_mock, get_environment_mock ): is_cname_available_mock.return_value = True find_solution_stack_from_string_mock.return_value = self.platform get_app_name_mock.return_value = 'my-application' get_env_name_mock.return_value = 'environment-1' get_cname_from_customer.return_value = 'my-cname' prompt_for_environment_name_mock.return_value = 'environment-1-clone' get_environment_names_mock.return_value = Environment.json_to_environment_objects_array( mock_responses.DESCRIBE_ENVIRONMENTS_RESPONSE['Environments'] ) get_environment_mock.return_value = environment_from_mock_responses('environment-1') clone_environment_request_mock.return_value = mock.MagicMock() clone_environment_request = clone_environment_request_mock.return_value app = EB(argv=['clone']) app.setup() app.run() prompt_for_environment_name_mock.assert_called_once_with( default_name='my-application-clone', prompt_text='Enter name for Environment Clone' ) clone_environment_request_mock.assert_called_once_with( app_name='environment-1', cname='my-cname', env_name='environment-1-clone', original_name='my-application', platform=self.platform, scale=None, tags=[] ) make_cloned_env_mock.assert_called_once_with( clone_environment_request, nohang=False, timeout=None )
def get_app_environments(app_name, include_deleted=False, deleted_back_to=None): LOG.debug('Inside get_app_environments api wrapper') kwargs = {} if include_deleted and deleted_back_to is not None: kwargs['IncludedDeletedBackTo'] = deleted_back_to result = _make_api_call('describe_environments', ApplicationName=app_name, IncludeDeleted=include_deleted, **kwargs) return Environment.json_to_environment_objects_array( result['Environments'])
def get_all_environments(): LOG.debug('Inside get_all_environments api wrapper') result = _make_api_call('describe_environments', IncludeDeleted=False) return Environment.json_to_environment_objects_array(result['Environments'])
def get_all_environments(): LOG.debug('Inside get_all_environments api wrapper') result = _make_api_call('describe_environments', IncludeDeleted=False) return Environment.json_to_environment_objects_array( result['Environments'])