<s> from django . core . urlresolvers import reverse <EOL> from django import http <EOL> from mox3 . mox import IsA <EOL> from horizon import exceptions <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 VolumeTypeTests ( test . BaseAdminViewTests ) : <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , ) } ) <EOL> def test_create_volume_type ( self ) : <EOL> formData = { '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> cinder . volume_type_create ( <EOL> IsA ( http . HttpRequest ) , <EOL> formData [ '<STR_LIT:name>' ] , <EOL> formData [ '<STR_LIT>' ] ) . AndReturn ( <EOL> self . cinder_volume_types . first ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , <EOL> formData ) <EOL> self . assertNoFormErrors ( res ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) } ) <EOL> def test_update_volume_type ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> formData = { '<STR_LIT:name>' : volume_type . name , <EOL> '<STR_LIT:description>' : '<STR_LIT>' } <EOL> volume_type = cinder . volume_type_get ( <EOL> IsA ( http . HttpRequest ) , volume_type . id ) . AndReturn ( volume_type ) <EOL> cinder . volume_type_update ( <EOL> IsA ( http . HttpRequest ) , <EOL> volume_type . id , <EOL> formData [ '<STR_LIT:name>' ] , <EOL> formData [ '<STR_LIT:description>' ] ) . AndReturn ( volume_type ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' , <EOL> args = [ volume_type . id ] ) <EOL> res = self . client . post ( url , formData ) <EOL> self . assertNoFormErrors ( res ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> @ test . create_stubs ( { api . nova : ( '<STR_LIT>' , ) , <EOL> cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_delete_volume_type ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> formData = { '<STR_LIT:action>' : '<STR_LIT>' % volume_type . id } <EOL> encryption_list = ( self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:0> ] , <EOL> self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:1> ] ) <EOL> cinder . volume_type_list_with_qos_associations ( <EOL> IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_volume_types . list ( ) ) <EOL> cinder . qos_spec_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_qos_specs . list ( ) ) <EOL> cinder . volume_encryption_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( encryption_list ) <EOL> cinder . volume_type_delete ( IsA ( http . HttpRequest ) , <EOL> volume_type . id ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( <EOL> 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> '<STR_LIT>' , <EOL> '<STR_LIT>' ) , <EOL> keystone : ( '<STR_LIT>' , ) } ) <EOL> def test_delete_volume_type_exception ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> formData = { '<STR_LIT:action>' : '<STR_LIT>' % volume_type . id } <EOL> encryption_list = ( self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:0> ] , <EOL> self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:1> ] ) <EOL> cinder . volume_type_list_with_qos_associations ( <EOL> IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_volume_types . list ( ) ) <EOL> cinder . qos_spec_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_qos_specs . list ( ) ) <EOL> cinder . volume_encryption_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( encryption_list ) <EOL> cinder . volume_type_delete ( IsA ( http . HttpRequest ) , <EOL> str ( volume_type . id ) ) . AndRaise ( exceptions . BadRequest ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , <EOL> formData ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , ) } ) <EOL> def test_create_volume_type_encryption ( self ) : <EOL> volume_type1 = self . cinder_volume_types . list ( ) [ <NUM_LIT:0> ] <EOL> volume_type2 = self . cinder_volume_types . list ( ) [ <NUM_LIT:1> ] <EOL> volume_type1 . id = u'<STR_LIT:1>' <EOL> volume_type2 . id = u'<STR_LIT:2>' <EOL> volume_type_list = [ volume_type1 , volume_type2 ] <EOL> formData = { '<STR_LIT:name>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : volume_type1 . id } <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volume_type_list ) <EOL> cinder . volume_encryption_type_create ( IsA ( http . HttpRequest ) , <EOL> formData [ '<STR_LIT>' ] , <EOL> formData ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> args = [ volume_type1 . id ] ) <EOL> res = self . client . post ( url , formData ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertTemplateUsed ( <EOL> res , <EOL> '<STR_LIT>' ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , ) } ) <EOL> def test_type_encryption_detail_view_unencrypted ( self ) : <EOL> volume_type1 = self . cinder_volume_types . list ( ) [ <NUM_LIT:0> ] <EOL> volume_type1 . id = u'<STR_LIT:1>' <EOL> volume_type_list = [ volume_type1 ] <EOL> vol_unenc_type = self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:2> ] <EOL> cinder . volume_encryption_type_get ( IsA ( http . HttpRequest ) , <EOL> volume_type1 . id ) . AndReturn ( vol_unenc_type ) <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volume_type_list ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> args = [ volume_type1 . id ] ) <EOL> res = self . client . get ( url ) <EOL> self . assertTemplateUsed ( <EOL> res , <EOL> '<STR_LIT>' ) <EOL> self . assertContains ( res , <EOL> "<STR_LIT>" , <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertNoMessages ( ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , ) } ) <EOL> def test_type_encryption_detail_view_encrypted ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> volume_type . id = u'<STR_LIT:1>' <EOL> volume_type . name = "<STR_LIT>" <EOL> volume_type_list = [ volume_type ] <EOL> vol_enc_type = self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:0> ] <EOL> cinder . volume_encryption_type_get ( IsA ( http . HttpRequest ) , <EOL> volume_type . id ) . AndReturn ( vol_enc_type ) <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volume_type_list ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> args = [ volume_type . id ] ) <EOL> res = self . client . get ( url ) <EOL> self . assertTemplateUsed ( <EOL> res , <EOL> '<STR_LIT>' ) <EOL> self . assertContains ( res , "<STR_LIT>" , <NUM_LIT:1> , <EOL> <NUM_LIT:200> ) <EOL> self . assertContains ( res , "<STR_LIT>" % volume_type . name , <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertContains ( res , "<STR_LIT>" % vol_enc_type . control_location , <EOL> <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertContains ( res , "<STR_LIT>" % vol_enc_type . key_size , <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertContains ( res , "<STR_LIT>" % vol_enc_type . provider , <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertContains ( res , "<STR_LIT>" % vol_enc_type . cipher , <NUM_LIT:1> , <NUM_LIT:200> ) <EOL> self . assertNoMessages ( ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) } ) <EOL> def test_delete_volume_type_encryption ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> volume_type . id = u'<STR_LIT:1>' <EOL> formData = { '<STR_LIT:action>' : '<STR_LIT>' % <EOL> volume_type . id } <EOL> encryption_list = ( self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:0> ] , <EOL> self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:1> ] ) <EOL> cinder . extension_supported ( IsA ( http . HttpRequest ) , <EOL> '<STR_LIT>' ) . AndReturn ( True ) <EOL> cinder . volume_type_list_with_qos_associations ( <EOL> IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_volume_types . list ( ) ) <EOL> cinder . qos_spec_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . cinder_qos_specs . list ( ) ) <EOL> cinder . volume_encryption_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( encryption_list ) <EOL> cinder . volume_encryption_type_delete ( IsA ( http . HttpRequest ) , <EOL> volume_type . id ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . post ( <EOL> reverse ( '<STR_LIT>' ) , <EOL> formData ) <EOL> redirect = reverse ( '<STR_LIT>' ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> @ test . create_stubs ( { cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) } ) <EOL> def test_update_volume_type_encryption ( self ) : <EOL> volume_type = self . cinder_volume_types . first ( ) <EOL> volume_type . id = u'<STR_LIT:1>' <EOL> volume_type_list = [ volume_type ] <EOL> formData = { '<STR_LIT:name>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : u'<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : volume_type . id } <EOL> vol_enc_type = self . cinder_volume_encryption_types . list ( ) [ <NUM_LIT:0> ] <EOL> cinder . volume_encryption_type_get ( IsA ( http . HttpRequest ) , <EOL> volume_type . id ) . AndReturn ( vol_enc_type ) <EOL> cinder . volume_type_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volume_type_list ) <EOL> cinder . volume_encryption_type_update ( IsA ( http . HttpRequest ) , <EOL> formData [ '<STR_LIT>' ] , <EOL> formData ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> args = [ volume_type . id ] ) <EOL> res = self . client . post ( url , formData ) <EOL> self . assertNoFormErrors ( res ) <EOL> self . assertTemplateUsed ( <EOL> res , <EOL> '<STR_LIT>' ) </s>
