<s> from django . core . urlresolvers import reverse <EOL> from django import http <EOL> from mox import IsA <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . api import cinder <EOL> from openstack_dashboard . api import keystone <EOL> from openstack_dashboard . test import helpers as test <EOL> class VolumeTests ( test . BaseAdminViewTests ) : <EOL> @ test . create_stubs ( { api . nova : ( '<STR_LIT>' , ) , <EOL> cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , ) , <EOL> keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_index ( self ) : <EOL> cinder . volume_list ( IsA ( http . HttpRequest ) , search_opts = { <EOL> '<STR_LIT>' : True } ) . AndReturn ( self . volumes . list ( ) ) <EOL> api . nova . server_list ( IsA ( http . HttpRequest ) , search_opts = { <EOL> '<STR_LIT>' : True } ) . AndReturn ( [ self . servers . list ( ) , False ] ) <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . volume_types . list ( ) ) <EOL> keystone . tenant_list ( IsA ( http . HttpRequest ) ) . AndReturn ( [ self . tenants . list ( ) , False ] ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . get ( reverse ( '<STR_LIT>' ) ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> volumes = res . context [ '<STR_LIT>' ] . data <EOL> self . assertItemsEqual ( volumes , self . volumes . list ( ) ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , ) } ) <EOL> def test_create_volume_type ( self ) : <EOL> formData = { '<STR_LIT:name>' : '<STR_LIT>' } <EOL> cinder . volume_type_create ( IsA ( http . HttpRequest ) , <EOL> formData [ '<STR_LIT:name>' ] ) . AndReturn ( self . volume_types . first ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( reverse ( '<STR_LIT>' ) , <EOL> formData ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> @ test . create_stubs ( { api . nova : ( '<STR_LIT>' , ) , <EOL> cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) , <EOL> keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_delete_volume_type ( self ) : <EOL> volume_type = self . volume_types . first ( ) <EOL> formData = { '<STR_LIT:action>' : '<STR_LIT>' % volume_type . id } <EOL> cinder . volume_list ( IsA ( http . HttpRequest ) , search_opts = { <EOL> '<STR_LIT>' : True } ) . AndReturn ( self . volumes . list ( ) ) <EOL> api . nova . server_list ( IsA ( http . HttpRequest ) , search_opts = { <EOL> '<STR_LIT>' : True } ) . AndReturn ( [ self . servers . list ( ) , False ] ) <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . volume_types . list ( ) ) <EOL> cinder . volume_type_delete ( IsA ( http . HttpRequest ) , <EOL> str ( volume_type . id ) ) <EOL> keystone . tenant_list ( IsA ( http . HttpRequest ) ) . AndReturn ( [ self . tenants . list ( ) , False ] ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( reverse ( '<STR_LIT>' ) , <EOL> formData ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) </s>
