#NEWLINE# @ mock . patch ( 'openstackclient.compute.v2.server.io.open' ) #NEWLINE# def test_server_create_userdata( self , mock_open ) : #NEWLINE# #INDENT# mock_file = mock . MagicMock ( name = 'File' ) #NEWLINE# mock_open . return_value = mock_file #NEWLINE# mock_open . read . return_value = '#!/bin/sh' #NEWLINE# arglist = [ '--image' , 'image1' , '--flavor' , 'flavor1' , '--user-data' , 'userdata.sh' , self . new_server . name ] #NEWLINE# verifylist = [ ( 'image' , 'image1' ) , ( 'flavor' , 'flavor1' ) , ( 'user_data' , 'userdata.sh' ) , ( 'config_drive' , False ) , ( 'server_name' , self . new_server . name ) ] #NEWLINE# parsed_args = self . check_parser ( self . cmd , arglist , verifylist ) #NEWLINE# ( columns , data ) = self . cmd . take_action ( parsed_args ) #NEWLINE# mock_open . assert_called_with ( 'userdata.sh' ) #NEWLINE# mock_file . close . assert_called_with ( ) #NEWLINE# kwargs = dict ( meta = None , files = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , reservation_id = None , min_count = 1 , max_count = 1 , security_groups = [ ] , userdata = mock_file , key_name = None , availability_zone = None , block_device_mapping = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , nics = [ ] , scheduler_hints = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , config_drive = None ) #NEWLINE# self . servers_mock . create . assert_called_with ( self . new_server . name , self . image , self . flavor , ** kwargs ) #NEWLINE# self . assertEqual ( self . columns , columns ) #NEWLINE# self . assertEqual ( self . datalist ( ) , data )