<s> from __future__ import absolute_import <EOL> from keystoneclient . v2_0 import client as keystone_client <EOL> from openstack_dashboard import api <EOL> from openstack_dashboard . test import helpers as test <EOL> class FakeConnection ( object ) : <EOL> pass <EOL> class ClientConnectionTests ( test . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ClientConnectionTests , self ) . setUp ( ) <EOL> self . mox . StubOutWithMock ( keystone_client , "<STR_LIT>" ) <EOL> self . internal_url = api . base . url_for ( self . request , <EOL> '<STR_LIT>' , <EOL> endpoint_type = '<STR_LIT>' ) <EOL> self . admin_url = api . base . url_for ( self . request , <EOL> '<STR_LIT>' , <EOL> endpoint_type = '<STR_LIT>' ) <EOL> self . conn = FakeConnection ( ) <EOL> class RoleAPITests ( test . APITestCase ) : <EOL> def setUp ( self ) : <EOL> super ( RoleAPITests , self ) . setUp ( ) <EOL> self . role = self . roles . member <EOL> self . roles = self . roles . list ( ) <EOL> def test_remove_tenant_user ( self ) : <EOL> """<STR_LIT>""" <EOL> keystoneclient = self . stub_keystoneclient ( ) <EOL> tenant = self . tenants . first ( ) <EOL> keystoneclient . roles = self . mox . CreateMockAnything ( ) <EOL> keystoneclient . roles . roles_for_user ( self . user . id , <EOL> tenant . id ) . AndReturn ( self . roles ) <EOL> for role in self . roles : <EOL> keystoneclient . roles . revoke ( role . id , <EOL> domain = None , <EOL> group = None , <EOL> project = tenant . id , <EOL> user = self . user . id ) <EOL> self . mox . ReplayAll ( ) <EOL> api . keystone . remove_tenant_user ( self . request , tenant . id , self . user . id ) <EOL> def test_get_default_role ( self ) : <EOL> keystoneclient = self . stub_keystoneclient ( ) <EOL> keystoneclient . roles = self . mox . CreateMockAnything ( ) <EOL> keystoneclient . roles . list ( ) . AndReturn ( self . roles ) <EOL> self . mox . ReplayAll ( ) <EOL> role = api . keystone . get_default_role ( self . request ) <EOL> self . assertEqual ( self . role , role ) <EOL> role = api . keystone . get_default_role ( self . request ) <EOL> class ServiceAPITests ( test . APITestCase ) : <EOL> def test_service_wrapper ( self ) : <EOL> catalog = self . service_catalog <EOL> identity_data = api . base . get_service_from_catalog ( catalog , "<STR_LIT>" ) <EOL> identity_data [ '<STR_LIT:id>' ] = <NUM_LIT:1> <EOL> region = identity_data [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> service = api . keystone . Service ( identity_data , region ) <EOL> self . assertEqual ( u"<STR_LIT>" , unicode ( service ) ) <EOL> self . assertEqual ( identity_data [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] , <EOL> service . region ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> service . url ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> service . public_url ) <EOL> self . assertEqual ( "<STR_LIT>" , service . host ) <EOL> def test_service_wrapper_service_in_region ( self ) : <EOL> catalog = self . service_catalog <EOL> compute_data = api . base . get_service_from_catalog ( catalog , "<STR_LIT>" ) <EOL> compute_data [ '<STR_LIT:id>' ] = <NUM_LIT:1> <EOL> region = compute_data [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] <EOL> service = api . keystone . Service ( compute_data , region ) <EOL> self . assertEqual ( u"<STR_LIT>" , unicode ( service ) ) <EOL> self . assertEqual ( compute_data [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] , <EOL> service . region ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> service . url ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> service . public_url ) <EOL> self . assertEqual ( "<STR_LIT>" , service . host ) </s>
