#NEWLINE# def test_already_exists( self ) : #NEWLINE# #INDENT# def db_key_pair_create_duplicate( context , keypair ) : #NEWLINE# #INDENT# raise exception . KeyPairExists ( key_name = keypair . get ( 'name' , '' ) ) #NEWLINE# #UNINDENT# self . stub_out ( 'nova.db.key_pair_create' , self ) #NEWLINE# msg = ( "Key pair '%(key_name)s' already exists." % { #NEWLINE# #INDENT# 'key_name' : self . existing_key_name , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertKeypairRaises ( exception . KeyPairExists , msg , self . existing_key_name )