<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> class SnapshotsViewTests ( test . TestCase ) : <EOL> def test_create_snapshot_get ( self ) : <EOL> server = self . servers . first ( ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> api . nova . server_get ( IsA ( http . HttpRequest ) , server . id ) . AndReturn ( server ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' , <EOL> args = [ server . id ] ) <EOL> res = self . client . get ( url ) <EOL> self . assertTemplateUsed ( res , <EOL> '<STR_LIT>' ) <EOL> def test_create_get_server_exception ( self ) : <EOL> server = self . servers . first ( ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> api . nova . server_get ( IsA ( http . HttpRequest ) , server . id ) . AndRaise ( self . exceptions . nova ) <EOL> self . mox . ReplayAll ( ) <EOL> url = reverse ( '<STR_LIT>' , <EOL> args = [ server . id ] ) <EOL> res = self . client . get ( url ) <EOL> redirect = reverse ( "<STR_LIT>" ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) <EOL> def test_create_snapshot_post ( self ) : <EOL> server = self . servers . first ( ) <EOL> snapshot = self . snapshots . first ( ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> api . nova . server_get ( IsA ( http . HttpRequest ) , server . id ) . AndReturn ( server ) <EOL> api . nova . snapshot_create ( IsA ( http . HttpRequest ) , server . id , <EOL> snapshot . name ) . AndReturn ( snapshot ) <EOL> self . mox . ReplayAll ( ) <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . tenant . id , <EOL> '<STR_LIT>' : server . id , <EOL> '<STR_LIT:name>' : snapshot . name } <EOL> url = reverse ( '<STR_LIT>' , <EOL> args = [ server . id ] ) <EOL> res = self . client . post ( url , formData ) <EOL> self . assertRedirectsNoFollow ( res , INDEX_URL ) <EOL> def test_create_snapshot_post_exception ( self ) : <EOL> server = self . servers . first ( ) <EOL> snapshot = self . snapshots . first ( ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( api . nova , '<STR_LIT>' ) <EOL> api . nova . snapshot_create ( IsA ( http . HttpRequest ) , server . id , <EOL> snapshot . name ) . AndRaise ( self . exceptions . nova ) <EOL> self . mox . ReplayAll ( ) <EOL> formData = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : self . tenant . id , <EOL> '<STR_LIT>' : server . id , <EOL> '<STR_LIT:name>' : snapshot . name } <EOL> url = reverse ( '<STR_LIT>' , <EOL> args = [ server . id ] ) <EOL> res = self . client . post ( url , formData ) <EOL> redirect = reverse ( "<STR_LIT>" ) <EOL> self . assertRedirectsNoFollow ( res , redirect ) </s>
