#NEWLINE# def test_switch_region( self , next = None ) : #NEWLINE# #INDENT# tenants = [ self . data . tenant_one , self . data . tenant_two ] #NEWLINE# user = self . data . user #NEWLINE# scoped = self . data . scoped_access_info #NEWLINE# sc = self . data . service_catalog #NEWLINE# form_data = self . get_form_data ( user ) #NEWLINE# self . _mock_unscoped_client_list_tenants ( user , tenants ) #NEWLINE# self . _mock_scoped_client_for_tenant ( scoped , self . data . tenant_one . id ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# url = reverse ( 'login' ) #NEWLINE# response = self . client . get ( url ) #NEWLINE# self . assertEqual ( response . status_code , 200 ) #NEWLINE# response = self . client . post ( url , form_data ) #NEWLINE# self . assertRedirects ( response , settings . LOGIN_REDIRECT_URL ) #NEWLINE# old_region = sc . get_endpoints ( ) [ 'compute' ] [ 0 ] [ 'region' ] #NEWLINE# self . assertEqual ( self . client . session [ 'services_region' ] , old_region ) #NEWLINE# region = sc . get_endpoints ( ) [ 'compute' ] [ 1 ] [ 'region' ] #NEWLINE# url = reverse ( 'switch_services_region' , args = [ region ] ) #NEWLINE# form_data [ 'region_name' ] = region #NEWLINE# if next : #NEWLINE# #INDENT# form_data . update ( { #NEWLINE# #INDENT# auth . REDIRECT_FIELD_NAME : next , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# response = self . client . get ( next , form_data ) #NEWLINE# if next : #NEWLINE# #INDENT# if ( django . VERSION >= ( 1 , 9 ) ) : #NEWLINE# #INDENT# expected_url = next #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# expected_url = ( 'http://testserver%s' % next ) #NEWLINE# #UNINDENT# self . assertEqual ( response [ 'location' ] , expected_url ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertRedirects ( response , settings . LOGIN_REDIRECT_URL ) #NEWLINE# #UNINDENT# self . assertEqual ( self . client . session [ 'services_region' ] , region ) #NEWLINE# self . assertEqual ( self . client . cookies [ 'services_region' ] . value , region )