<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 . test import helpers as test <EOL> INDEX_URL = reverse ( '<STR_LIT>' ) <EOL> VOLUME_SNAPSHOTS_TAB_URL = reverse ( '<STR_LIT>' ) <EOL> VOLUME_BACKUPS_TAB_URL = reverse ( '<STR_LIT>' ) <EOL> class VolumeAndSnapshotsTests ( test . TestCase ) : <EOL> @ test . create_stubs ( { api . cinder : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) , <EOL> api . nova : ( '<STR_LIT>' , ) } ) <EOL> def _test_index ( self , backup_supported = True ) : <EOL> vol_backups = self . cinder_volume_backups . list ( ) <EOL> vol_snaps = self . cinder_volume_snapshots . list ( ) <EOL> volumes = self . cinder_volumes . list ( ) <EOL> api . cinder . volume_backup_supported ( IsA ( http . HttpRequest ) ) . MultipleTimes ( ) . AndReturn ( backup_supported ) <EOL> api . cinder . volume_list ( IsA ( http . HttpRequest ) , search_opts = None ) . AndReturn ( volumes ) <EOL> api . nova . server_list ( IsA ( http . HttpRequest ) , search_opts = None ) . AndReturn ( [ self . servers . list ( ) , False ] ) <EOL> api . cinder . volume_snapshot_list ( <EOL> IsA ( http . HttpRequest ) , search_opts = None ) . AndReturn ( vol_snaps ) <EOL> api . cinder . volume_snapshot_list ( IsA ( http . HttpRequest ) ) . AndReturn ( vol_snaps ) <EOL> api . cinder . volume_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volumes ) <EOL> if backup_supported : <EOL> api . cinder . volume_backup_list ( IsA ( http . HttpRequest ) ) . AndReturn ( vol_backups ) <EOL> api . cinder . volume_list ( IsA ( http . HttpRequest ) ) . AndReturn ( volumes ) <EOL> api . cinder . tenant_absolute_limits ( IsA ( http . HttpRequest ) ) . MultipleTimes ( ) . AndReturn ( self . cinder_limits [ '<STR_LIT>' ] ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . get ( INDEX_URL ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> res = self . client . get ( VOLUME_SNAPSHOTS_TAB_URL ) <EOL> self . assertEqual ( res . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> if backup_supported : <EOL> res = self . client . get ( VOLUME_BACKUPS_TAB_URL ) <EOL> self . assertTemplateUsed ( res , '<STR_LIT>' ) <EOL> def test_index_backup_supported ( self ) : <EOL> self . _test_index ( backup_supported = True ) <EOL> def test_index_backup_not_supported ( self ) : <EOL> self . _test_index ( backup_supported = False ) </s>
