#NEWLINE# def test_nsxv_str( self ) : #NEWLINE# #INDENT# ' Test for Nsxv._str_ ' #NEWLINE# exp_info = 2 #NEWLINE# pol = policy . ParsePolicy ( nsxv_mocktest . MIXED_FILTER , self . defs , False ) #NEWLINE# target = nsxv . Nsxv ( pol , value ) #NEWLINE# root = ET . fromstring ( str ( target ) ) #NEWLINE# section_name = { #NEWLINE# #INDENT# 'id' : '1009' , #NEWLINE# 'name' : 'Sample mixed NSXV filter' , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( root . attrib , section_name ) #NEWLINE# self . assertEqual ( root . find ( './rule/name' ) . text , 'accept-to-honestdns' ) #NEWLINE# self . assertEqual ( root . find ( './rule/action' ) . text , 'allow' ) #NEWLINE# exp_ipv4dest = [ '8.8.4.4' , '8.8.8.8' ] #NEWLINE# exp_ipv6dest = [ '2001:4860:4860::8844' , '2001:4860:4860::8888' ] #NEWLINE# for destination in root . findall ( './rule/destinations/destination' ) : #NEWLINE# #INDENT# type = destination . find ( 'type' ) . text #NEWLINE# value = destination . find ( 'value' ) . text #NEWLINE# if ( 'Ipv4Address' in type ) : #NEWLINE# #INDENT# if ( value not in exp_ipv4dest ) : #NEWLINE# #INDENT# self . fail ( 'IPv4Address not found in test_nsxv_str()' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( value not in exp_ipv6dest ) : #NEWLINE# #INDENT# self . fail ( 'IPv6Address not found in test_nsxv_str()' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# protocol = int ( root . find ( './rule/services/service/protocol' ) . text ) #NEWLINE# self . assertEqual ( protocol , 17 ) #NEWLINE# destination_port = root . find ( './rule/services/service/destinationPort' ) . text #NEWLINE# self . assertEqual ( destination_port , '53' ) #NEWLINE# notes = root . find ( './rule/notes' ) . text #NEWLINE# self . assertEqual ( notes , 'Allow name resolution using honestdns.' )