#NEWLINE# @ mock . patch ( 'awscli.customizations.datapipeline.CreateDefaultRoles._construct_result' ) #NEWLINE# @ mock . patch ( 'awscli.customizations.datapipeline.CreateDefaultRoles._check_if_role_exists' ) #NEWLINE# @ mock . patch ( 'awscli.customizations.datapipeline.CreateDefaultRoles._check_if_instance_profile_exists' ) #NEWLINE# @ mock . patch ( 'awscli.customizations.datapipeline.CreateDefaultRoles._get_role_policy' ) #NEWLINE# def test_default_roles_not_exist( self , get_rp_patch , role_exists_patch , instance_profile_exists_patch , construct_result_patch ) : #NEWLINE# #INDENT# get_rp_patch . return_value = False #NEWLINE# instance_profile_exists_patch . return_value = False #NEWLINE# role_exists_patch . return_value = False #NEWLINE# construct_result_patch . return_value = [ ] #NEWLINE# self . run_cmd ( self . prefix , expected_rc = 0 ) #NEWLINE# self . assertEqual ( len ( self . operations_called ) , 6 ) #NEWLINE# self . assertEqual ( self . operations_called [ 0 ] [ 0 ] . name , 'CreateRole' ) #NEWLINE# self . assertEqual ( self . operations_called [ 0 ] [ 1 ] [ 'RoleName' ] , DATAPIPELINE_DEFAULT_SERVICE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 0 ] [ 1 ] [ 'AssumeRolePolicyDocument' ] , dict_to_string ( DATAPIPELINE_DEFAULT_SERVICE_ROLE_ASSUME_POLICY ) ) #NEWLINE# self . assertEqual ( instance_profile_exists_patch . operations_called [ 1 ] [ 0 ] . name , 'AttachRolePolicy' ) #NEWLINE# self . assertEqual ( self . operations_called [ 1 ] [ 1 ] [ 'PolicyArn' ] , createdefaultroles . DATAPIPELINE_DEFAULT_SERVICE_ROLE_ARN ) #NEWLINE# self . assertEqual ( self . operations_called [ 1 ] [ 1 ] [ 'RoleName' ] , DATAPIPELINE_DEFAULT_SERVICE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 2 ] [ 0 ] . name , 'CreateRole' ) #NEWLINE# self . assertEqual ( self . operations_called [ 2 ] [ 1 ] [ 'RoleName' ] , DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 2 ] [ 1 ] [ 'AssumeRolePolicyDocument' ] , dict_to_string ( DATAPIPELINE_DEFAULT_RESOURCE_ROLE_ASSUME_POLICY ) ) #NEWLINE# self . assertEqual ( self . operations_called [ 3 ] [ 0 ] . name , 'AttachRolePolicy' ) #NEWLINE# self . assertEqual ( self . operations_called [ 3 ] [ 1 ] [ 'PolicyArn' ] , createdefaultroles . DATAPIPELINE_DEFAULT_RESOURCE_ROLE_ARN ) #NEWLINE# self . assertEqual ( self . operations_called [ 3 ] [ 1 ] [ 'RoleName' ] , DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 4 ] [ 0 ] . name , 'CreateInstanceProfile' ) #NEWLINE# self . assertEqual ( self . operations_called [ 4 ] [ 1 ] [ 'InstanceProfileName' ] , DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 5 ] [ 0 ] . name , 'AddRoleToInstanceProfile' ) #NEWLINE# self . assertEqual ( self . operations_called [ 5 ] [ 1 ] [ 'InstanceProfileName' ] , DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME ) #NEWLINE# self . assertEqual ( self . operations_called [ 5 ] [ 1 ] [ 'RoleName' ] , DATAPIPELINE_DEFAULT_RESOURCE_ROLE_NAME )