Created
October 19, 2012 18:15
-
-
Save dpgoetz/3919748 to your computer and use it in GitHub Desktop.
unit test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py | |
| index 4eeed3a..3ee2edf 100644 | |
| --- a/test/unit/proxy/test_server.py | |
| +++ b/test/unit/proxy/test_server.py | |
| @@ -46,7 +46,7 @@ from swift.common.exceptions import ChunkReadTimeout | |
| from swift.common.constraints import MAX_META_NAME_LENGTH, \ | |
| MAX_META_VALUE_LENGTH, MAX_META_COUNT, MAX_META_OVERALL_SIZE, \ | |
| MAX_FILE_SIZE, MAX_ACCOUNT_NAME_LENGTH, MAX_CONTAINER_NAME_LENGTH | |
| -from swift.common.utils import mkdirs, normalize_timestamp, NullLogger | |
| +from swift.common.utils import mkdirs, normalize_timestamp, NullLogger, public | |
| from swift.common.wsgi import monkey_patch_mimetools | |
| from swift.proxy.controllers.obj import SegmentedIterable | |
| from swift.proxy.controllers.base import get_container_memcache_key, \ | |
| @@ -784,17 +784,28 @@ class TestObjectController(unittest.TestCase): | |
| def test_GET_large_file_with_range(self): | |
| calls = [0] | |
| + get_calls = [0] | |
| + obj_get = [None, None] | |
| def handler(_junk1, _junk2): | |
| calls[0] += 1 | |
| + @public | |
| + def get_override(req): | |
| + get_calls[0] += 1 | |
| + return obj_get[0](req) | |
| + | |
| old_handler = signal.signal(signal.SIGPIPE, handler) | |
| try: | |
| prolis = _test_sockets[0] | |
| prosrv = _test_servers[0] | |
| + obj_get[0] = _test_servers[5].GET | |
| + obj_get[1] = _test_servers[6].GET | |
| + _test_servers[5].GET = get_override | |
| + _test_servers[6].GET = get_override | |
| sock = connect_tcp(('localhost', prolis.getsockname()[1])) | |
| fd = sock.makefile() | |
| - obj = 'a' * (1024 * 1024) | |
| + obj = 'a' * 1024 | |
| path = '/v1/a/c/o.large' | |
| fd.write('PUT %s HTTP/1.1\r\n' | |
| 'Host: localhost\r\n' | |
| @@ -816,7 +827,10 @@ class TestObjectController(unittest.TestCase): | |
| self.assertEqual(res.status_int, 206) | |
| self.assertEqual(res.body, obj[100:]) | |
| self.assertEqual(calls[0], 0) | |
| + self.assertEqual(get_calls[0], 1) | |
| finally: | |
| + _test_servers[5].GET = obj_get[0] | |
| + _test_servers[6].GET = obj_get[1] | |
| signal.signal(signal.SIGPIPE, old_handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment