#NEWLINE# def test_server_update_security_groups( self ) : #NEWLINE# #INDENT# all_secgroups = self . security_groups . list ( ) #NEWLINE# added_secgroup = all_secgroups [ 2 ] #NEWLINE# rm_secgroup = all_secgroups [ 0 ] #NEWLINE# cur_secgroups_raw = [ { #NEWLINE# #INDENT# 'id' : sg . id , #NEWLINE# 'name' : sg . name , #NEWLINE# 'rules' : [ ] , #NEWLINE# #UNINDENT# } for sg in all_secgroups [ 0 : 2 ] ] #NEWLINE# cur_secgroups_ret = { #NEWLINE# #INDENT# 'security_groups' : cur_secgroups_raw , #NEWLINE# #UNINDENT# } #NEWLINE# new_sg_ids = [ sg . id for sg in all_secgroups [ 1 : 3 ] ] #NEWLINE# instance_id = self . servers . first ( ) . id #NEWLINE# novaclient = self . stub_novaclient ( ) #NEWLINE# novaclient . security_groups = self . mox . CreateMockAnything ( ) #NEWLINE# novaclient . servers = self . mox . CreateMockAnything ( ) #NEWLINE# novaclient . client = self . mox . CreateMockAnything ( ) #NEWLINE# novaclient . security_groups . list ( ) . AndReturn ( all_secgroups ) #NEWLINE# url = ( '/servers/%s/os-security-groups' % instance_id ) #NEWLINE# novaclient . client . get ( url ) . AndReturn ( ( 200 , new_sg_ids ) ) #NEWLINE# novaclient . servers . add_security_group ( instance_id , added_secgroup . name ) #NEWLINE# novaclient . servers . remove_security_group ( instance_id , rm_secgroup . name ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# api . network . server_update_security_groups ( self . request , instance_id , new_sg_ids )