#NEWLINE# def test_get_with_name_duplicated( self ) : #NEWLINE# #INDENT# sg_name = 'web_server' #NEWLINE# expected_sg_id = '85cc3048-abc3-43cc-89b3-377341426ac5' #NEWLINE# list_security_groups = { #NEWLINE# #INDENT# 'security_groups' : [ { #NEWLINE# #INDENT# 'name' : sg_name , #NEWLINE# 'id' : expected_sg_id , #NEWLINE# 'tenant_id' : self . context . tenant , #NEWLINE# 'description' : 'server' , #NEWLINE# 'rules' : [ ] , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# self . mocked_client . list_security_groups . return_value = list_security_groups #NEWLINE# expected_sg = { #NEWLINE# #INDENT# 'security_group' : { #NEWLINE# #INDENT# 'name' : sg_name , #NEWLINE# 'id' : expected_sg_id , #NEWLINE# 'tenant_id' : self . context . tenant , #NEWLINE# 'description' : 'server' , #NEWLINE# 'rules' : [ ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . mocked_client . show_security_group . return_value = expected_sg #NEWLINE# self . mocked_client . EXTED_PLURALS = client . Client . EXTED_PLURALS #NEWLINE# sg_api = neutron_driver . SecurityGroupAPI ( ) #NEWLINE# observed_sg = sg_api . get ( self . context , name = sg_name ) #NEWLINE# expected_sg [ 'security_group' ] [ 'project_id' ] = self . context . tenant #NEWLINE# del expected_sg [ 'security_group' ] [ 'tenant_id' ] #NEWLINE# self . assertEqual ( expected_sg [ 'security_group' ] , observed_sg ) #NEWLINE# self . mocked_client . list_security_groups . assert_called_once_with ( name = sg_name , fields = 'id' , tenant_id = self . context . tenant ) #NEWLINE# self . mocked_client . show_security_group . assert_called_once_with ( expected_sg_id )