<s> import mock <EOL> from oslotest import base as test_base <EOL> import webob <EOL> from ec2api . api import faults <EOL> from ec2api import wsgi <EOL> class FakeResponse ( object ) : <EOL> reason = "<STR_LIT>" <EOL> def __init__ ( self , status_code = <NUM_LIT> ) : <EOL> self . status_code = status_code <EOL> def json ( self ) : <EOL> return { } <EOL> class TestFaults ( test_base . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_fault_exception ( self ) : <EOL> fault = faults . Fault ( webob . exc . HTTPBadRequest ( <EOL> explanation = '<STR_LIT:test>' ) ) <EOL> self . assertIsInstance ( fault . wrapped_exc , webob . exc . HTTPBadRequest ) <EOL> def test_fault_exception_status_int ( self ) : <EOL> fault = faults . Fault ( webob . exc . HTTPNotFound ( explanation = '<STR_LIT:test>' ) ) <EOL> self . assertEqual ( fault . wrapped_exc . status_int , <NUM_LIT> ) <EOL> @ mock . patch . object ( faults , '<STR_LIT>' , <EOL> return_value = FakeResponse ( ) ) <EOL> def test_fault_call ( self , mock_request ) : <EOL> message = '<STR_LIT>' <EOL> ex = webob . exc . HTTPNotFound ( explanation = message ) <EOL> fault = faults . Fault ( ex ) <EOL> req = wsgi . Request . blank ( '<STR_LIT>' ) <EOL> req . GET [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> fault ( req ) <EOL> mock_request . assert_called_with ( mock . ANY , '<STR_LIT>' , <EOL> message = message , status = ex . status_int ) </s>
