#NEWLINE# def test_network_assignment_when_node_created_and_added( self ) : #NEWLINE# #INDENT# cluster = self . env . create_cluster ( api = True , editable_attributes = { #NEWLINE# #INDENT# 'public_network_assignment' : { #NEWLINE# #INDENT# 'assign_to_all_nodes' : { #NEWLINE# #INDENT# 'value' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# mac = self . env . generate_random_mac ( ) #NEWLINE# meta = self . env . default_metadata ( ) #NEWLINE# self . env . set_interfaces_in_meta ( meta , [ { #NEWLINE# #INDENT# 'name' : 'eth0' , #NEWLINE# 'mac' : cluster , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'name' : 'eth1' , #NEWLINE# 'mac' : self . env . generate_random_mac ( ) , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# node = self . env . create_node ( api = True , meta = meta , mac = mac , cluster_id = cluster [ 'id' ] ) #NEWLINE# resp = self . app . get ( reverse ( 'NodeNICsHandler' , kwargs = { #NEWLINE# #INDENT# 'node_id' : node [ 'id' ] , #NEWLINE# #UNINDENT# } ) , headers = self . default_headers ) #NEWLINE# self . assertEqual ( resp . status_code , 200 ) #NEWLINE# for resp_nic in resp . json_body : #NEWLINE# #INDENT# net_names = [ net [ 'name' ] for net in resp_nic [ 'assigned_networks' ] ] #NEWLINE# if ( resp_nic [ 'mac' ] == mac ) : #NEWLINE# #INDENT# self . assertTrue ( ( 'fuelweb_admin' in net_names ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertTrue ( ( 'public' in net_names ) ) #NEWLINE# #UNINDENT# self . assertGreater ( len ( resp_nic [ 'assigned_networks' ] ) , 0 )