assertEquals is deprecated, use assertEqual (H602)
Change-Id: I75dac8693c079a153004f77dc1cda48f3ac6f51d
This commit is contained in:
parent
68dde8dd51
commit
0cded7cfed
@ -93,14 +93,14 @@ class TestJsonImport(testtools.TestCase):
|
|||||||
# this case is stested in _no_json
|
# this case is stested in _no_json
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.assertEquals(loads, c.json_loads)
|
self.assertEqual(loads, c.json_loads)
|
||||||
|
|
||||||
|
|
||||||
class TestConfigTrueValue(testtools.TestCase):
|
class TestConfigTrueValue(testtools.TestCase):
|
||||||
|
|
||||||
def test_TRUE_VALUES(self):
|
def test_TRUE_VALUES(self):
|
||||||
for v in u.TRUE_VALUES:
|
for v in u.TRUE_VALUES:
|
||||||
self.assertEquals(v, v.lower())
|
self.assertEqual(v, v.lower())
|
||||||
|
|
||||||
def test_config_true_value(self):
|
def test_config_true_value(self):
|
||||||
orig_trues = u.TRUE_VALUES
|
orig_trues = u.TRUE_VALUES
|
||||||
@ -135,7 +135,7 @@ class MockHttpTest(testtools.TestCase):
|
|||||||
|
|
||||||
def request(method, url, *args, **kwargs):
|
def request(method, url, *args, **kwargs):
|
||||||
if query_string:
|
if query_string:
|
||||||
self.assert_(url.endswith('?' + query_string))
|
self.assertTrue(url.endswith('?' + query_string))
|
||||||
return
|
return
|
||||||
conn.request = request
|
conn.request = request
|
||||||
|
|
||||||
@ -178,9 +178,9 @@ class TestHttpHelpers(MockHttpTest):
|
|||||||
|
|
||||||
def test_quote(self):
|
def test_quote(self):
|
||||||
value = 'standard string'
|
value = 'standard string'
|
||||||
self.assertEquals('standard%20string', c.quote(value))
|
self.assertEqual('standard%20string', c.quote(value))
|
||||||
value = u'\u0075nicode string'
|
value = u'\u0075nicode string'
|
||||||
self.assertEquals('unicode%20string', c.quote(value))
|
self.assertEqual('unicode%20string', c.quote(value))
|
||||||
|
|
||||||
def test_http_connection(self):
|
def test_http_connection(self):
|
||||||
url = 'http://www.test.com'
|
url = 'http://www.test.com'
|
||||||
@ -195,7 +195,7 @@ class TestHttpHelpers(MockHttpTest):
|
|||||||
|
|
||||||
def test_validate_headers(self):
|
def test_validate_headers(self):
|
||||||
headers = {'key': 'value'}
|
headers = {'key': 'value'}
|
||||||
self.assertEquals(c.validate_headers(headers), None)
|
self.assertEqual(c.validate_headers(headers), None)
|
||||||
|
|
||||||
headers = {'key': 'value1\nvalue2'}
|
headers = {'key': 'value1\nvalue2'}
|
||||||
self.assertRaises(c.InvalidHeadersException, c.validate_headers,
|
self.assertRaises(c.InvalidHeadersException, c.validate_headers,
|
||||||
@ -213,8 +213,8 @@ class TestGetAuth(MockHttpTest):
|
|||||||
def test_ok(self):
|
def test_ok(self):
|
||||||
c.http_connection = self.fake_http_connection(200)
|
c.http_connection = self.fake_http_connection(200)
|
||||||
url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf')
|
url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf')
|
||||||
self.assertEquals(url, None)
|
self.assertEqual(url, None)
|
||||||
self.assertEquals(token, None)
|
self.assertEqual(token, None)
|
||||||
|
|
||||||
def test_invalid_auth(self):
|
def test_invalid_auth(self):
|
||||||
c.http_connection = self.fake_http_connection(200)
|
c.http_connection = self.fake_http_connection(200)
|
||||||
@ -226,8 +226,8 @@ class TestGetAuth(MockHttpTest):
|
|||||||
c.http_connection = self.fake_http_connection(200)
|
c.http_connection = self.fake_http_connection(200)
|
||||||
url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
|
url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf',
|
||||||
auth_version="1.0")
|
auth_version="1.0")
|
||||||
self.assertEquals(url, None)
|
self.assertEqual(url, None)
|
||||||
self.assertEquals(token, None)
|
self.assertEqual(token, None)
|
||||||
|
|
||||||
def test_auth_v2(self):
|
def test_auth_v2(self):
|
||||||
os_options = {'tenant_name': 'asdf'}
|
os_options = {'tenant_name': 'asdf'}
|
||||||
@ -371,7 +371,7 @@ class TestGetAccount(MockHttpTest):
|
|||||||
def test_no_content(self):
|
def test_no_content(self):
|
||||||
c.http_connection = self.fake_http_connection(204)
|
c.http_connection = self.fake_http_connection(204)
|
||||||
value = c.get_account('http://www.test.com', 'asdf')[1]
|
value = c.get_account('http://www.test.com', 'asdf')[1]
|
||||||
self.assertEquals(value, [])
|
self.assertEqual(value, [])
|
||||||
|
|
||||||
def test_param_marker(self):
|
def test_param_marker(self):
|
||||||
c.http_connection = self.fake_http_connection(
|
c.http_connection = self.fake_http_connection(
|
||||||
@ -406,7 +406,7 @@ class TestHeadAccount(MockHttpTest):
|
|||||||
# TODO: Hmm. This doesn't really test too much as it uses a fake that
|
# TODO: Hmm. This doesn't really test too much as it uses a fake that
|
||||||
# always returns the same dict. I guess it "exercises" the code, so
|
# always returns the same dict. I guess it "exercises" the code, so
|
||||||
# I'll leave it for now.
|
# I'll leave it for now.
|
||||||
self.assertEquals(type(value), dict)
|
self.assertEqual(type(value), dict)
|
||||||
|
|
||||||
def test_server_error(self):
|
def test_server_error(self):
|
||||||
body = 'c' * 65
|
body = 'c' * 65
|
||||||
@ -417,7 +417,7 @@ class TestHeadAccount(MockHttpTest):
|
|||||||
c.head_account('http://www.tests.com', 'asdf')
|
c.head_account('http://www.tests.com', 'asdf')
|
||||||
except c.ClientException as e:
|
except c.ClientException as e:
|
||||||
new_body = "[first 60 chars of response] " + body[0:60]
|
new_body = "[first 60 chars of response] " + body[0:60]
|
||||||
self.assertEquals(e.__str__()[-89:], new_body)
|
self.assertEqual(e.__str__()[-89:], new_body)
|
||||||
|
|
||||||
|
|
||||||
class TestGetContainer(MockHttpTest):
|
class TestGetContainer(MockHttpTest):
|
||||||
@ -425,7 +425,7 @@ class TestGetContainer(MockHttpTest):
|
|||||||
def test_no_content(self):
|
def test_no_content(self):
|
||||||
c.http_connection = self.fake_http_connection(204)
|
c.http_connection = self.fake_http_connection(204)
|
||||||
value = c.get_container('http://www.test.com', 'asdf', 'asdf')[1]
|
value = c.get_container('http://www.test.com', 'asdf', 'asdf')[1]
|
||||||
self.assertEquals(value, [])
|
self.assertEqual(value, [])
|
||||||
|
|
||||||
def test_param_marker(self):
|
def test_param_marker(self):
|
||||||
c.http_connection = self.fake_http_connection(
|
c.http_connection = self.fake_http_connection(
|
||||||
@ -477,7 +477,7 @@ class TestHeadContainer(MockHttpTest):
|
|||||||
try:
|
try:
|
||||||
c.head_container('http://www.test.com', 'asdf', 'asdf')
|
c.head_container('http://www.test.com', 'asdf', 'asdf')
|
||||||
except c.ClientException as e:
|
except c.ClientException as e:
|
||||||
self.assertEquals(e.http_response_content, body)
|
self.assertEqual(e.http_response_content, body)
|
||||||
|
|
||||||
|
|
||||||
class TestPutContainer(MockHttpTest):
|
class TestPutContainer(MockHttpTest):
|
||||||
@ -485,7 +485,7 @@ class TestPutContainer(MockHttpTest):
|
|||||||
def test_ok(self):
|
def test_ok(self):
|
||||||
c.http_connection = self.fake_http_connection(200)
|
c.http_connection = self.fake_http_connection(200)
|
||||||
value = c.put_container('http://www.test.com', 'asdf', 'asdf')
|
value = c.put_container('http://www.test.com', 'asdf', 'asdf')
|
||||||
self.assertEquals(value, None)
|
self.assertEqual(value, None)
|
||||||
|
|
||||||
def test_server_error(self):
|
def test_server_error(self):
|
||||||
body = 'c' * 60
|
body = 'c' * 60
|
||||||
@ -496,7 +496,7 @@ class TestPutContainer(MockHttpTest):
|
|||||||
try:
|
try:
|
||||||
c.put_container('http://www.test.com', 'asdf', 'asdf')
|
c.put_container('http://www.test.com', 'asdf', 'asdf')
|
||||||
except c.ClientException as e:
|
except c.ClientException as e:
|
||||||
self.assertEquals(e.http_response_content, body)
|
self.assertEqual(e.http_response_content, body)
|
||||||
|
|
||||||
|
|
||||||
class TestDeleteContainer(MockHttpTest):
|
class TestDeleteContainer(MockHttpTest):
|
||||||
@ -504,7 +504,7 @@ class TestDeleteContainer(MockHttpTest):
|
|||||||
def test_ok(self):
|
def test_ok(self):
|
||||||
c.http_connection = self.fake_http_connection(200)
|
c.http_connection = self.fake_http_connection(200)
|
||||||
value = c.delete_container('http://www.test.com', 'asdf', 'asdf')
|
value = c.delete_container('http://www.test.com', 'asdf', 'asdf')
|
||||||
self.assertEquals(value, None)
|
self.assertEqual(value, None)
|
||||||
|
|
||||||
|
|
||||||
class TestGetObject(MockHttpTest):
|
class TestGetObject(MockHttpTest):
|
||||||
@ -538,7 +538,7 @@ class TestGetObject(MockHttpTest):
|
|||||||
"No headers in the request")
|
"No headers in the request")
|
||||||
self.assertTrue('Range' in request_args['headers'],
|
self.assertTrue('Range' in request_args['headers'],
|
||||||
"No Range header in the request")
|
"No Range header in the request")
|
||||||
self.assertEquals(request_args['headers']['Range'], 'bytes=1-2')
|
self.assertEqual(request_args['headers']['Range'], 'bytes=1-2')
|
||||||
|
|
||||||
|
|
||||||
class TestHeadObject(MockHttpTest):
|
class TestHeadObject(MockHttpTest):
|
||||||
@ -586,14 +586,14 @@ class TestPutObject(MockHttpTest):
|
|||||||
conn[1].send = resp.fake_send
|
conn[1].send = resp.fake_send
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
c.put_object(*args, chunk_size=20, headers={}, http_conn=conn)
|
c.put_object(*args, chunk_size=20, headers={}, http_conn=conn)
|
||||||
self.assertEquals(len(w), 0)
|
self.assertEqual(len(w), 0)
|
||||||
|
|
||||||
body = 'c' * 60
|
body = 'c' * 60
|
||||||
c.http_connection = self.fake_http_connection(200, body=body)
|
c.http_connection = self.fake_http_connection(200, body=body)
|
||||||
args = ('http://www.test.com', 'asdf', 'asdf', 'asdf', 'asdf')
|
args = ('http://www.test.com', 'asdf', 'asdf', 'asdf', 'asdf')
|
||||||
with warnings.catch_warnings(record=True) as w:
|
with warnings.catch_warnings(record=True) as w:
|
||||||
c.put_object(*args, chunk_size=20)
|
c.put_object(*args, chunk_size=20)
|
||||||
self.assertEquals(len(w), 1)
|
self.assertEqual(len(w), 1)
|
||||||
self.assertTrue(issubclass(w[-1].category, UserWarning))
|
self.assertTrue(issubclass(w[-1].category, UserWarning))
|
||||||
|
|
||||||
def test_server_error(self):
|
def test_server_error(self):
|
||||||
@ -604,7 +604,7 @@ class TestPutObject(MockHttpTest):
|
|||||||
try:
|
try:
|
||||||
c.put_object(*args)
|
c.put_object(*args)
|
||||||
except c.ClientException as e:
|
except c.ClientException as e:
|
||||||
self.assertEquals(e.http_response_content, body)
|
self.assertEqual(e.http_response_content, body)
|
||||||
|
|
||||||
def test_query_string(self):
|
def test_query_string(self):
|
||||||
c.http_connection = self.fake_http_connection(200,
|
c.http_connection = self.fake_http_connection(200,
|
||||||
@ -645,7 +645,7 @@ class TestPostObject(MockHttpTest):
|
|||||||
try:
|
try:
|
||||||
c.post_object(*args)
|
c.post_object(*args)
|
||||||
except c.ClientException as e:
|
except c.ClientException as e:
|
||||||
self.assertEquals(e.http_response_content, body)
|
self.assertEqual(e.http_response_content, body)
|
||||||
|
|
||||||
|
|
||||||
class TestDeleteObject(MockHttpTest):
|
class TestDeleteObject(MockHttpTest):
|
||||||
@ -670,7 +670,7 @@ class TestConnection(MockHttpTest):
|
|||||||
|
|
||||||
def test_instance(self):
|
def test_instance(self):
|
||||||
conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
|
conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
|
||||||
self.assertEquals(conn.retries, 5)
|
self.assertEqual(conn.retries, 5)
|
||||||
|
|
||||||
def test_instance_kwargs(self):
|
def test_instance_kwargs(self):
|
||||||
args = {'user': 'ausername',
|
args = {'user': 'ausername',
|
||||||
@ -678,13 +678,13 @@ class TestConnection(MockHttpTest):
|
|||||||
'authurl': 'http://www.test.com',
|
'authurl': 'http://www.test.com',
|
||||||
'tenant_name': 'atenant'}
|
'tenant_name': 'atenant'}
|
||||||
conn = c.Connection(**args)
|
conn = c.Connection(**args)
|
||||||
self.assertEquals(type(conn), c.Connection)
|
self.assertEqual(type(conn), c.Connection)
|
||||||
|
|
||||||
def test_instance_kwargs_token(self):
|
def test_instance_kwargs_token(self):
|
||||||
args = {'preauthtoken': 'atoken123',
|
args = {'preauthtoken': 'atoken123',
|
||||||
'preauthurl': 'http://www.test.com:8080/v1/AUTH_123456'}
|
'preauthurl': 'http://www.test.com:8080/v1/AUTH_123456'}
|
||||||
conn = c.Connection(**args)
|
conn = c.Connection(**args)
|
||||||
self.assertEquals(type(conn), c.Connection)
|
self.assertEqual(type(conn), c.Connection)
|
||||||
|
|
||||||
def test_storage_url_override(self):
|
def test_storage_url_override(self):
|
||||||
static_url = 'http://overridden.storage.url'
|
static_url = 'http://overridden.storage.url'
|
||||||
@ -721,7 +721,7 @@ class TestConnection(MockHttpTest):
|
|||||||
c.sleep = quick_sleep
|
c.sleep = quick_sleep
|
||||||
conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
|
conn = c.Connection('http://www.test.com', 'asdf', 'asdf')
|
||||||
self.assertRaises(c.ClientException, conn.head_account)
|
self.assertRaises(c.ClientException, conn.head_account)
|
||||||
self.assertEquals(conn.attempts, conn.retries + 1)
|
self.assertEqual(conn.attempts, conn.retries + 1)
|
||||||
|
|
||||||
def test_resp_read_on_server_error(self):
|
def test_resp_read_on_server_error(self):
|
||||||
c.http_connection = self.fake_http_connection(500)
|
c.http_connection = self.fake_http_connection(500)
|
||||||
@ -774,16 +774,16 @@ class TestConnection(MockHttpTest):
|
|||||||
preauthtoken='old',
|
preauthtoken='old',
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(conn.attempts, 0)
|
self.assertEqual(conn.attempts, 0)
|
||||||
self.assertEquals(conn.url, 'http://www.old.com')
|
self.assertEqual(conn.url, 'http://www.old.com')
|
||||||
self.assertEquals(conn.token, 'old')
|
self.assertEqual(conn.token, 'old')
|
||||||
|
|
||||||
conn.head_account()
|
conn.head_account()
|
||||||
|
|
||||||
self.assertTrue(self.swap_sleep_called)
|
self.assertTrue(self.swap_sleep_called)
|
||||||
self.assertEquals(conn.attempts, 2)
|
self.assertEqual(conn.attempts, 2)
|
||||||
self.assertEquals(conn.url, 'http://www.new.com')
|
self.assertEqual(conn.url, 'http://www.new.com')
|
||||||
self.assertEquals(conn.token, 'new')
|
self.assertEqual(conn.token, 'new')
|
||||||
|
|
||||||
def test_reset_stream(self):
|
def test_reset_stream(self):
|
||||||
|
|
||||||
@ -857,8 +857,8 @@ class TestConnection(MockHttpTest):
|
|||||||
conn.put_object('c', 'o', contents)
|
conn.put_object('c', 'o', contents)
|
||||||
except socket.error as err:
|
except socket.error as err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertEquals(contents.seeks, [0])
|
self.assertEqual(contents.seeks, [0])
|
||||||
self.assertEquals(str(exc), 'oops')
|
self.assertEqual(str(exc), 'oops')
|
||||||
|
|
||||||
contents = LocalContents(tell_value=123)
|
contents = LocalContents(tell_value=123)
|
||||||
exc = None
|
exc = None
|
||||||
@ -866,8 +866,8 @@ class TestConnection(MockHttpTest):
|
|||||||
conn.put_object('c', 'o', contents)
|
conn.put_object('c', 'o', contents)
|
||||||
except socket.error as err:
|
except socket.error as err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertEquals(contents.seeks, [123])
|
self.assertEqual(contents.seeks, [123])
|
||||||
self.assertEquals(str(exc), 'oops')
|
self.assertEqual(str(exc), 'oops')
|
||||||
|
|
||||||
contents = LocalContents()
|
contents = LocalContents()
|
||||||
contents.tell = None
|
contents.tell = None
|
||||||
@ -876,8 +876,8 @@ class TestConnection(MockHttpTest):
|
|||||||
conn.put_object('c', 'o', contents)
|
conn.put_object('c', 'o', contents)
|
||||||
except c.ClientException as err:
|
except c.ClientException as err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertEquals(contents.seeks, [])
|
self.assertEqual(contents.seeks, [])
|
||||||
self.assertEquals(str(exc), "put_object('c', 'o', ...) failure "
|
self.assertEqual(str(exc), "put_object('c', 'o', ...) failure "
|
||||||
"and no ability to reset contents for reupload.")
|
"and no ability to reset contents for reupload.")
|
||||||
finally:
|
finally:
|
||||||
c.http_connection = orig_conn
|
c.http_connection = orig_conn
|
||||||
|
Loading…
x
Reference in New Issue
Block a user