<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> DETAILS_URL = reverse ( <EOL> '<STR_LIT>' , args = [ '<STR_LIT:id>' ] ) <EOL> class DataProcessingJobBinaryTests ( test . TestCase ) : <EOL> @ test . create_stubs ( { api . sahara : ( '<STR_LIT>' , ) } ) <EOL> def test_index ( self ) : <EOL> api . sahara . job_binary_list ( IsA ( http . HttpRequest ) ) . AndReturn ( self . job_binaries . list ( ) ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . get ( INDEX_URL ) <EOL> self . assertTemplateUsed ( <EOL> res , '<STR_LIT>' ) <EOL> self . assertContains ( res , '<STR_LIT>' ) <EOL> self . assertContains ( res , '<STR_LIT:Name>' ) <EOL> self . assertContains ( res , '<STR_LIT>' ) <EOL> @ test . create_stubs ( { api . sahara : ( '<STR_LIT>' , ) } ) <EOL> def test_details ( self ) : <EOL> api . sahara . job_binary_get ( IsA ( http . HttpRequest ) , IsA ( unicode ) ) . AndReturn ( self . job_binaries . list ( ) [ <NUM_LIT:0> ] ) <EOL> self . mox . ReplayAll ( ) <EOL> res = self . client . get ( DETAILS_URL ) <EOL> self . assertTemplateUsed ( <EOL> res , '<STR_LIT>' ) <EOL> self . assertContains ( res , '<STR_LIT>' ) <EOL> @ test . create_stubs ( { api . sahara : ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , ) } ) <EOL> def test_delete ( self ) : <EOL> jb_list = ( api . sahara . job_binary_list ( IsA ( http . HttpRequest ) ) <EOL> . AndReturn ( self . job_binaries . list ( ) ) ) <EOL> api . sahara . job_binary_get ( IsA ( http . HttpRequest ) , IsA ( unicode ) ) . AndReturn ( self . job_binaries . list ( ) [ <NUM_LIT:0> ] ) <EOL> api . sahara . job_binary_delete ( IsA ( http . HttpRequest ) , jb_list [ <NUM_LIT:0> ] . id ) <EOL> int_id = jb_list [ <NUM_LIT:0> ] . url . split ( "<STR_LIT>" ) [ <NUM_LIT:1> ] <EOL> api . sahara . job_binary_internal_delete ( IsA ( http . HttpRequest ) , int_id ) <EOL> self . mox . ReplayAll ( ) <EOL> form_data = { "<STR_LIT:action>" : "<STR_LIT>" % jb_list [ <NUM_LIT:0> ] . id } <EOL> res = self . client . post ( INDEX_URL , form_data ) <EOL> self . assertRedirectsNoFollow ( res , INDEX_URL ) <EOL> @ test . create_stubs ( { api . sahara : ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) } ) <EOL> def test_download ( self ) : <EOL> jb = api . sahara . job_binary_get ( IsA ( http . HttpRequest ) , IsA ( unicode ) ) . AndReturn ( self . job_binaries . list ( ) [ <NUM_LIT:0> ] ) <EOL> api . sahara . job_binary_get_file ( IsA ( http . HttpRequest ) , jb . id ) . AndReturn ( "<STR_LIT>" ) <EOL> self . mox . ReplayAll ( ) <EOL> context = { '<STR_LIT>' : jb . id } <EOL> url = reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : jb . id } ) <EOL> res = self . client . get ( url , context ) <EOL> self . assertTrue ( res . has_header ( '<STR_LIT>' ) ) <EOL> @ test . create_stubs ( { api . sahara : ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) } ) <EOL> def test_download_with_spaces ( self ) : <EOL> jb = api . sahara . job_binary_get ( IsA ( http . HttpRequest ) , IsA ( unicode ) ) . AndReturn ( self . job_binaries . list ( ) [ <NUM_LIT:1> ] ) <EOL> api . sahara . job_binary_get_file ( IsA ( http . HttpRequest ) , jb . id ) . AndReturn ( "<STR_LIT>" ) <EOL> self . mox . ReplayAll ( ) <EOL> context = { '<STR_LIT>' : jb . id } <EOL> url = reverse ( '<STR_LIT>' , <EOL> kwargs = { '<STR_LIT>' : jb . id } ) <EOL> res = self . client . get ( url , context ) <EOL> self . assertEqual ( <EOL> res . get ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' % jb . name <EOL> ) </s>
