Merge "Add Status Code tests for Container GET"
This commit is contained in:
commit
a32b411f22
@ -225,6 +225,40 @@ class TestContainerController(TestRingBase):
|
|||||||
self.app, self.container_ring.devs[2]),
|
self.app, self.container_ring.devs[2]),
|
||||||
self.app.error_suppression_limit + 1)
|
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):
|
def test_response_code_for_PUT(self):
|
||||||
PUT_TEST_CASES = [
|
PUT_TEST_CASES = [
|
||||||
((201, 201, 201), 201),
|
((201, 201, 201), 201),
|
||||||
|
Loading…
Reference in New Issue
Block a user