#NEWLINE# @ skipIf ( ( sys . version_info < ( 2 , 7 ) ) , 'ElementTree version 1.3 required which comes with Python 2.7' ) #NEWLINE# @ patch ( 'salt.modules.virt._nic_profile' ) #NEWLINE# @ patch ( 'salt.modules.virt._disk_profile' ) #NEWLINE# def test_gen_xml_for_esxi_custom_profile( self , disk_profile , nic_profile ) : #NEWLINE# #INDENT# diskp_yaml = '\n- first:\n    size: 8192\n    format: vmdk\n    model: scsi\n    pool: datastore1\n- second:\n    size: 4096\n    format: vmdk  # FIX remove line, currently test fails\n    model: scsi   # FIX remove line, currently test fails\n    pool: datastore2\n' #NEWLINE# nicp_yaml = "\n- type: bridge\n  name: eth1\n  source: ONENET\n  model: e1000\n  mac: '00:00:00:00:00:00'\n- name: eth2\n  type: bridge\n  source: TWONET\n  model: e1000\n  mac: '00:00:00:00:00:00'\n" #NEWLINE# disk_profile . return_value = yaml . load ( diskp_yaml ) #NEWLINE# nic_profile . return_value = yaml . load ( nicp_yaml ) #NEWLINE# diskp = virt . _disk_profile ( 'noeffect' , 'esxi' ) #NEWLINE# nicp = virt . _nic_profile ( 'noeffect' , 'esxi' ) #NEWLINE# xml_data = virt . _gen_xml ( 'hello' , 1 , 512 , diskp , nicp , 'esxi' ) #NEWLINE# root = ET . fromstring ( xml_data ) #NEWLINE# self . assertEqual ( root . attrib [ 'type' ] , 'vmware' ) #NEWLINE# self . assertEqual ( root . find ( 'vcpu' ) . text , '1' ) #NEWLINE# self . assertEqual ( root . find ( 'memory' ) . text , str ( ( 512 * 1024 ) ) ) #NEWLINE# self . assertEqual ( root . find ( 'memory' ) . attrib [ 'unit' ] , 'KiB' ) #NEWLINE# self . assertTrue ( ( len ( root . findall ( './/disk' ) ) == 2 ) ) #NEWLINE# self . assertTrue ( ( len ( root . findall ( './/interface' ) ) == 2 ) )