#NEWLINE# @ mock . patch ( 'nova.objects.Flavor._flavor_get_by_flavor_id_from_db' , side_effect = exception . FlavorNotFound ( flavor_id = 'foo' ) ) #NEWLINE# def test_add_tenant_access( self , mock_api_get ) : #NEWLINE# #INDENT# def stub_add_flavor_access( context , flavorid , projectid ) : #NEWLINE# #INDENT# self . assertEqual ( '3' , flavorid , 'flavorid' ) #NEWLINE# self . assertEqual ( 'proj2' , projectid , 'projectid' ) #NEWLINE# #UNINDENT# self . stub_out ( 'nova.db.flavor_access_add' , stub_add_flavor_access ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'flavor_access' : [ { #NEWLINE# #INDENT# 'flavor_id' : '3' , #NEWLINE# 'tenant_id' : 'proj3' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } #NEWLINE# body = { #NEWLINE# #INDENT# 'addTenantAccess' : { #NEWLINE# #INDENT# 'tenant' : 'proj2' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# req = fakes . HTTPRequest . blank ( ( self . _prefix + '/flavors/2/action' ) , use_admin_context = True ) #NEWLINE# add_access = self . _get_add_access ( ) #NEWLINE# result = add_access ( req , '3' , body = body ) #NEWLINE# self . assertEqual ( result , expected )