<s> import ceilometerclient . exc as ceilometer_exceptions <EOL> from cinderclient import exceptions as cinder_exceptions <EOL> import glanceclient . exc as glance_exceptions <EOL> from keystoneclient import exceptions as keystone_exceptions <EOL> from neutronclient . common import exceptions as neutron_exceptions <EOL> from novaclient import exceptions as nova_exceptions <EOL> import six <EOL> from swiftclient import client as swift_exceptions <EOL> from openstack_dashboard . test . test_data import utils <EOL> def create_stubbed_exception ( cls , status_code = <NUM_LIT> ) : <EOL> msg = "<STR_LIT>" <EOL> def fake_init_exception ( self , code = None , message = None , ** kwargs ) : <EOL> if code is not None : <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> self . http_status = code <EOL> else : <EOL> self . code = code <EOL> self . message = message or self . __class__ . message <EOL> try : <EOL> self . message = self . message % kwargs <EOL> except Exception : <EOL> pass <EOL> def fake_str ( self ) : <EOL> return str ( self . message ) <EOL> def fake_unicode ( self ) : <EOL> return six . text_type ( self . message ) <EOL> cls . __init__ = fake_init_exception <EOL> cls . __str__ = fake_str <EOL> cls . __unicode__ = fake_unicode <EOL> cls . silence_logging = True <EOL> return cls ( status_code , msg ) <EOL> def data ( TEST ) : <EOL> TEST . exceptions = utils . TestDataContainer ( ) <EOL> unauth = keystone_exceptions . Unauthorized <EOL> TEST . exceptions . keystone_unauthorized = create_stubbed_exception ( unauth ) <EOL> keystone_exception = keystone_exceptions . ClientException <EOL> TEST . exceptions . keystone = create_stubbed_exception ( keystone_exception ) <EOL> nova_exception = nova_exceptions . ClientException <EOL> TEST . exceptions . nova = create_stubbed_exception ( nova_exception ) <EOL> nova_unauth = nova_exceptions . Unauthorized <EOL> TEST . exceptions . nova_unauthorized = create_stubbed_exception ( nova_unauth ) <EOL> glance_exception = glance_exceptions . ClientException <EOL> TEST . exceptions . glance = create_stubbed_exception ( glance_exception ) <EOL> ceilometer_exception = ceilometer_exceptions . HTTPException <EOL> TEST . exceptions . ceilometer = create_stubbed_exception ( ceilometer_exception ) <EOL> neutron_exception = neutron_exceptions . NeutronClientException <EOL> TEST . exceptions . neutron = create_stubbed_exception ( neutron_exception ) <EOL> swift_exception = swift_exceptions . ClientException <EOL> TEST . exceptions . swift = create_stubbed_exception ( swift_exception ) <EOL> cinder_exception = cinder_exceptions . BadRequest <EOL> TEST . exceptions . cinder = create_stubbed_exception ( cinder_exception ) </s>
