From e99965693550977a7abcf3b8e71299fade0b8f94 Mon Sep 17 00:00:00 2001 From: David Goetz Date: Mon, 11 Apr 2011 16:26:50 -0700 Subject: [PATCH] unit tests for timeout exception --- test/probe/test_container_failures.py | 2 ++ test/unit/proxy/test_server.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/probe/test_container_failures.py b/test/probe/test_container_failures.py index 585835d2a8..380f5c2816 100755 --- a/test/probe/test_container_failures.py +++ b/test/probe/test_container_failures.py @@ -316,6 +316,8 @@ class TestContainerFailures(unittest.TestCase): self.assert_(object2 in [o['name'] for o in client.get_container(self.url, self.token, container)[1]]) + def test_locked_container_dbs(self): + pass if __name__ == '__main__': unittest.main() diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index 782a31d2c5..bbfc93c894 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -161,8 +161,10 @@ def fake_http_connect(*code_iter, **kwargs): self.body = body def getresponse(self): - if 'raise_exc' in kwargs: + if kwargs.get('raise_exc'): raise Exception('test') + if kwargs.get('raise_timeout_exc'): + raise TimeoutError() return self def getexpect(self): @@ -341,6 +343,14 @@ class TestController(unittest.TestCase): self.assertEqual(p, partition) self.assertEqual(n, nodes) + def test_make_requests(self): + with save_globals(): + proxy_server.http_connect = fake_http_connect(200) + partition, nodes = self.controller.account_info(self.account) + proxy_server.http_connect = fake_http_connect(201, + raise_timeout_exc=True) + self.controller._make_request(nodes, partition, 'POST','/','','') + # tests if 200 is cached and used def test_account_info_200(self): with save_globals(): @@ -1893,8 +1903,8 @@ class TestObjectController(unittest.TestCase): _test_sockets orig_update_request = prosrv.update_request - def broken_update_request(env, req): - raise Exception('fake') + def broken_update_request(*args, **kwargs): + raise Exception('fake: this should be printed') prosrv.update_request = broken_update_request sock = connect_tcp(('localhost', prolis.getsockname()[1]))