confirmed pending patch with webob 1.0; resolved only known issue with webob trunk, some pep8 cleanup
This commit is contained in:
parent
1c5490e29d
commit
456dea9295
@ -67,25 +67,33 @@ def mock_http_connect(response, headers=None, with_exc=False):
|
|||||||
self.headers = headers
|
self.headers = headers
|
||||||
if self.headers is None:
|
if self.headers is None:
|
||||||
self.headers = {}
|
self.headers = {}
|
||||||
|
|
||||||
def getresponse(self):
|
def getresponse(self):
|
||||||
if self.with_exc:
|
if self.with_exc:
|
||||||
raise Exception('test')
|
raise Exception('test')
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def getheader(self, header):
|
def getheader(self, header):
|
||||||
return self.headers[header]
|
return self.headers[header]
|
||||||
|
|
||||||
def read(self, amt=None):
|
def read(self, amt=None):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
return lambda *args, **kwargs: FakeConn(response, headers, with_exc)
|
return lambda *args, **kwargs: FakeConn(response, headers, with_exc)
|
||||||
|
|
||||||
|
|
||||||
class Logger(object):
|
class Logger(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.error_value = None
|
self.error_value = None
|
||||||
self.exception_value = None
|
self.exception_value = None
|
||||||
|
|
||||||
def error(self, msg, *args, **kwargs):
|
def error(self, msg, *args, **kwargs):
|
||||||
self.error_value = (msg, args, kwargs)
|
self.error_value = (msg, args, kwargs)
|
||||||
|
|
||||||
def exception(self, msg, *args, **kwargs):
|
def exception(self, msg, *args, **kwargs):
|
||||||
_, exc, _ = sys.exc_info()
|
_, exc, _ = sys.exc_info()
|
||||||
self.exception_value = (msg,
|
self.exception_value = (msg,
|
||||||
@ -99,7 +107,7 @@ class FakeApp(object):
|
|||||||
|
|
||||||
def __call__(self, env, start_response):
|
def __call__(self, env, start_response):
|
||||||
self.i_was_called = True
|
self.i_was_called = True
|
||||||
req = Request(env)
|
req = Request.blank('', environ=env)
|
||||||
if 'swift.authorize' in env:
|
if 'swift.authorize' in env:
|
||||||
resp = env['swift.authorize'](req)
|
resp = env['swift.authorize'](req)
|
||||||
if resp:
|
if resp:
|
||||||
@ -110,6 +118,7 @@ class FakeApp(object):
|
|||||||
def start_response(*args):
|
def start_response(*args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestAuth(unittest.TestCase):
|
class TestAuth(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -418,6 +427,5 @@ class TestAuth(unittest.TestCase):
|
|||||||
self.assert_(resp.startswith('403'), resp)
|
self.assert_(resp.startswith('403'), resp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user