Add Status Code tests for Container GET
I think a real easy list of status maps checks is missing for the container unittests. At least I hope I didn't miss it? This one uses all some pretty decent modern infrastructure so it should be easy to expand. Change-Id: I0929dad87214569cfd5ee3896840a92cc10c621f
This commit is contained in:
parent
f7bf483a49
commit
d37d077cb1
@ -225,6 +225,40 @@ class TestContainerController(TestRingBase):
|
||||
self.app, self.container_ring.devs[2]),
|
||||
self.app.error_suppression_limit + 1)
|
||||
|
||||
def test_response_codes_for_GET(self):
|
||||
nodes = self.app.container_ring.replicas
|
||||
handoffs = self.app.request_node_count(nodes) - nodes
|
||||
GET_TEST_CASES = [
|
||||
([], 503),
|
||||
([200], 200),
|
||||
([404, 200], 200),
|
||||
([404] * nodes + [200], 200),
|
||||
([Timeout()] * nodes + [404] * handoffs, 404),
|
||||
([Timeout()] * (nodes + handoffs), 503),
|
||||
([Timeout()] * (nodes + handoffs - 1) + [404], 404),
|
||||
([503, 200], 200),
|
||||
([507, 200], 200),
|
||||
]
|
||||
failures = []
|
||||
for case, expected in GET_TEST_CASES:
|
||||
try:
|
||||
with mocked_http_conn(*case):
|
||||
req = Request.blank('/v1/a/c')
|
||||
resp = req.get_response(self.app)
|
||||
try:
|
||||
self.assertEqual(resp.status_int, expected)
|
||||
except AssertionError:
|
||||
msg = '%r => %s (expected %s)' % (
|
||||
case, resp.status_int, expected)
|
||||
failures.append(msg)
|
||||
except AssertionError as e:
|
||||
# left over status failure
|
||||
msg = '%r => %s' % (case, e)
|
||||
failures.append(msg)
|
||||
if failures:
|
||||
self.fail('Some requests did not have expected response:\n' +
|
||||
'\n'.join(failures))
|
||||
|
||||
def test_response_code_for_PUT(self):
|
||||
PUT_TEST_CASES = [
|
||||
((201, 201, 201), 201),
|
||||
|
Loading…
Reference in New Issue
Block a user