#NEWLINE# def test_prefix_node( self ) : #NEWLINE# #INDENT# ' Test node constraints\n\n            Setting the node value is not allowed for all prefix types. Make\n            sure the constraints are working correctly.\n        ' #NEWLINE# expected = { #NEWLINE# #INDENT# 'alarm_priority' : None , #NEWLINE# 'authoritative_source' : 'nipap' , #NEWLINE# 'avps' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'comment' : None , #NEWLINE# 'country' : None , #NEWLINE# 'type' : 'assignment' , #NEWLINE# 'description' : 'test prefix' , #NEWLINE# 'display_prefix' : '1.3.2.0/24' , #NEWLINE# 'expires' : None , #NEWLINE# 'external_key' : None , #NEWLINE# 'family' : 4 , #NEWLINE# 'indent' : 0 , #NEWLINE# 'inherited_tags' : [ ] , #NEWLINE# 'monitor' : None , #NEWLINE# 'node' : None , #NEWLINE# 'order_id' : None , #NEWLINE# 'customer_id' : None , #NEWLINE# 'pool_name' : None , #NEWLINE# 'pool_id' : None , #NEWLINE# 'tags' : [ ] , #NEWLINE# 'vrf_rt' : None , #NEWLINE# 'vrf_id' : 0 , #NEWLINE# 'vrf_name' : 'default' , #NEWLINE# 'vlan' : None , #NEWLINE# 'status' : 'assigned' , #NEWLINE# #UNINDENT# } #NEWLINE# expected_list = [ ] #NEWLINE# attr = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# attr [ 'prefix' ] = '1.3.2.0/24' #NEWLINE# attr [ 'description' ] = 'test prefix' #NEWLINE# attr [ 'type' ] = 'assignment' #NEWLINE# res = s . add_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# 'attr' : attr , #NEWLINE# #UNINDENT# } ) #NEWLINE# exp1 = expected . copy ( ) #NEWLINE# exp1 . update ( attr ) #NEWLINE# exp1 [ 'id' ] = res [ 'id' ] #NEWLINE# attr [ 'prefix' ] = '1.3.3.0/24' #NEWLINE# attr [ 'node' ] = 'test' #NEWLINE# attr [ 'type' ] = 'reservation' #NEWLINE# with self . assertRaisesRegexp ( xmlrpclib . Fault , "Not allowed to set 'node' value for prefixes of type 'reservation'." ) : #NEWLINE# #INDENT# s . add_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# 'attr' : attr , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# attr [ 'type' ] = 'assignment' #NEWLINE# with self . assertRaisesRegexp ( xmlrpclib . Fault , "Not allowed to set 'node' value for prefixes of type 'assignment' which do not have all bits set in netmask." ) : #NEWLINE# #INDENT# s . add_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# 'attr' : attr , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# attr [ 'prefix' ] = '1.3.3.0/32' #NEWLINE# res = s . add_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# 'attr' : attr , #NEWLINE# #UNINDENT# } ) #NEWLINE# exp2 = expected . copy ( ) #NEWLINE# exp2 . update ( attr ) #NEWLINE# exp2 [ 'id' ] = res [ 'id' ] #NEWLINE# exp2 [ 'display_prefix' ] = '1.3.3.0' #NEWLINE# attr [ 'type' ] = 'host' #NEWLINE# attr [ 'prefix' ] = '1.3.2.1/32' #NEWLINE# res = s . add_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# 'attr' : attr , #NEWLINE# #UNINDENT# } ) #NEWLINE# exp3 = expected . copy ( ) #NEWLINE# exp3 . update ( attr ) #NEWLINE# exp3 [ 'id' ] = res [ 'id' ] #NEWLINE# exp3 [ 'display_prefix' ] = '1.3.2.1/24' #NEWLINE# exp3 [ 'indent' ] = 1 #NEWLINE# expected_list . append ( exp1 ) #NEWLINE# expected_list . append ( exp3 ) #NEWLINE# expected_list . append ( exp2 ) #NEWLINE# res = self . _mangle_prefix_result ( s . list_prefix ( { #NEWLINE# #INDENT# 'auth' : ad , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . assertEqual ( res , expected_list )