fixed ugly code pattern in probe tests

Change-Id: I242f095ea0ca8d6d69c3b2258cce6b51c7963dce
This commit is contained in:
John Dickinson 2015-02-26 14:21:47 -08:00
parent 37fb2cef04
commit da6f8d8f13
3 changed files with 25 additions and 25 deletions

View File

@ -107,13 +107,13 @@ class TestContainerFailures(ReplProbeTest):
# because the one node that knew about the delete replicated to the
# others.)
for cnode in cnodes:
exc = None
try:
direct_client.direct_get_container(cnode, cpart, self.account,
container1)
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
# Assert account level also indicates container1 is gone
headers, containers = client.get_account(self.url, self.token)
@ -150,12 +150,12 @@ class TestContainerFailures(ReplProbeTest):
db_conn.execute('begin exclusive transaction')
db_conns.append(db_conn)
if catch_503:
exc = None
try:
client.delete_container(self.url, self.token, container)
except client.ClientException as err:
exc = err
self.assertEquals(exc.http_status, 503)
self.assertEquals(err.http_status, 503)
else:
self.fail("Expected ClientException but didn't get it")
else:
client.delete_container(self.url, self.token, container)

View File

@ -124,15 +124,15 @@ class TestEmptyDevice(ReplProbeTest):
# Assert that it doesn't have container/obj yet
self.assertFalse(os.path.exists(obj_dir))
exc = None
try:
direct_client.direct_get_object(
onode, opart, self.account, container, obj, headers={
'X-Backend-Storage-Policy-Index': self.policy.idx})
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertFalse(os.path.exists(obj_dir))
self.assertEquals(err.http_status, 404)
self.assertFalse(os.path.exists(obj_dir))
else:
self.fail("Expected ClientException but didn't get it")
try:
port_num = onode['replication_port']
@ -160,14 +160,14 @@ class TestEmptyDevice(ReplProbeTest):
'it returned: %s' % repr(odata))
# Assert the handoff server no longer has container/obj
exc = None
try:
direct_client.direct_get_object(
another_onode, opart, self.account, container, obj, headers={
'X-Backend-Storage-Policy-Index': self.policy.idx})
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
if __name__ == '__main__':
main()

View File

@ -91,14 +91,14 @@ class TestObjectHandoff(ReplProbeTest):
start_server(onode['port'], self.port2server, self.pids)
# Assert that it doesn't have container/obj yet
exc = None
try:
direct_client.direct_get_object(
onode, opart, self.account, container, obj, headers={
'X-Backend-Storage-Policy-Index': self.policy.idx})
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
# Run object replication, ensuring we run the handoff node last so it
# will remove its extra handoff partition
@ -125,14 +125,14 @@ class TestObjectHandoff(ReplProbeTest):
'it returned: %s' % repr(odata))
# Assert the handoff server no longer has container/obj
exc = None
try:
direct_client.direct_get_object(
another_onode, opart, self.account, container, obj, headers={
'X-Backend-Storage-Policy-Index': self.policy.idx})
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
# Kill the first container/obj primary server again (we have two
# primaries and the handoff up now)
@ -150,12 +150,12 @@ class TestObjectHandoff(ReplProbeTest):
self.assertEqual(503, err.http_status)
# Assert we can't head container/obj
exc = None
try:
client.head_object(self.url, self.token, container, obj)
except client.ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
# Assert container/obj is not in the container listing, both indirectly
# and directly
@ -193,14 +193,14 @@ class TestObjectHandoff(ReplProbeTest):
Manager(['object-replicator']).once(number=another_node_id)
# Assert primary node no longer has container/obj
exc = None
try:
direct_client.direct_get_object(
another_onode, opart, self.account, container, obj, headers={
'X-Backend-Storage-Policy-Index': self.policy.idx})
except ClientException as err:
exc = err
self.assertEquals(exc.http_status, 404)
self.assertEquals(err.http_status, 404)
else:
self.fail("Expected ClientException but didn't get it")
if __name__ == '__main__':