From 64d24076842559fcfc5d654eaf3a303b3112ea38 Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Tue, 19 Sep 2017 18:11:09 -0700 Subject: [PATCH] Follow-up test fixup Use more literals to make test more obvious/readable - DAMP not DRY. Change-Id: I2562085c829dbc2c812d8e624d6b71a7ccee91ed Related-Change-Id: Ie153d01479c4242c01f48bf0ada78c2f9b6c8ff0 --- test/unit/proxy/controllers/test_base.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/unit/proxy/controllers/test_base.py b/test/unit/proxy/controllers/test_base.py index cef1f90999..60d17c9ec8 100644 --- a/test/unit/proxy/controllers/test_base.py +++ b/test/unit/proxy/controllers/test_base.py @@ -888,6 +888,8 @@ class TestFuncs(unittest.TestCase): return '' def getheader(self, header): + # content-length for the whole object is generated dynamically + # by summing non-None chunks initialized as source1 if header.lower() == "content-length": return str(sum(len(c) for c in self.chunks if c is not None)) @@ -897,13 +899,11 @@ class TestFuncs(unittest.TestCase): node = {'ip': '1.2.3.4', 'port': 6200, 'device': 'sda'} - data = ['abcd', '1234', 'efgh', '5678', 'lots', 'more', 'data'] - - # NB: content length on source1 should be correct - # but that reversed piece never makes it to the client - source1 = TestSource(data[:2] + [data[2][::-1], None] + data[3:]) - source2 = TestSource(data[2:4] + ['nope', None]) - source3 = TestSource(data[4:]) + source1 = TestSource(['abcd', '1234', None, + 'efgh', '5678', 'lots', 'more', 'data']) + # incomplete reads of client_chunk_size will be re-fetched + source2 = TestSource(['efgh', '5678', 'lots', None]) + source3 = TestSource(['lots', 'more', 'data']) req = Request.blank('/v1/a/c/o') handler = GetOrHeadHandler( self.app, req, 'Object', None, None, None, {},