pep8 fix: assertEquals -> assertEqual

assertEquals is deprecated in py3, replacing it.

Change-Id: Ida206abbb13c320095bb9e3b25a2b66cc31bfba8
Co-Authored-By: Ondřej Nový <ondrej.novy@firma.seznam.cz>
This commit is contained in:
janonymous 2015-08-05 23:58:14 +05:30 committed by Ondřej Nový
parent 6b854bd908
commit f5f9d791b0
48 changed files with 3117 additions and 3117 deletions

View File

@ -2863,7 +2863,7 @@ class TestObjectVersioning(Base):
container = self.env.container
versions_container = self.env.versions_container
cont_info = container.info()
self.assertEquals(cont_info['versions'], versions_container.name)
self.assertEqual(cont_info['versions'], versions_container.name)
obj_name = Utils.create_name()

View File

@ -187,7 +187,7 @@ class TestAccountFailures(ReplProbeTest):
found2 = True
self.assertEqual(container['count'], 2)
self.assertEqual(container['bytes'], 9)
self.assertEquals(container['bytes'], 9)
self.assertEqual(container['bytes'], 9)
self.assertFalse(found1)
self.assertTrue(found2)

View File

@ -97,7 +97,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache})
res = req.get_response(app)
# Response code of 200 because authentication itself is not done here
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_no_quotas(self):
headers = [('x-account-bytes-used', '1000'), ]
@ -107,7 +107,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_obj_request_ignores_attempt_to_set_quotas(self):
# If you try to set X-Account-Meta-* on an object, it's ignored, so
@ -121,7 +121,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_container_request_ignores_attempt_to_set_quotas(self):
# As with an object, if you try to set X-Account-Meta-* on a
@ -134,7 +134,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_bogus_quota_is_ignored(self):
# This can happen if the metadata was set by a user prior to the
@ -147,7 +147,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_bytes_quota(self):
headers = [('x-account-bytes-used', '1000'),
@ -158,8 +158,8 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_quota_not_authorized(self):
headers = [('x-account-bytes-used', '1000'),
@ -171,7 +171,7 @@ class TestAccountQuota(unittest.TestCase):
headers={'x-auth-token': 'bad-secret'},
environ={'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 403)
self.assertEqual(res.status_int, 403)
def test_exceed_quota_authorized(self):
headers = [('x-account-bytes-used', '1000'),
@ -183,7 +183,7 @@ class TestAccountQuota(unittest.TestCase):
headers={'x-auth-token': 'secret'},
environ={'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEqual(res.status_int, 413)
def test_under_quota_not_authorized(self):
headers = [('x-account-bytes-used', '0'),
@ -195,7 +195,7 @@ class TestAccountQuota(unittest.TestCase):
headers={'x-auth-token': 'bad-secret'},
environ={'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 403)
self.assertEqual(res.status_int, 403)
def test_under_quota_authorized(self):
headers = [('x-account-bytes-used', '0'),
@ -207,7 +207,7 @@ class TestAccountQuota(unittest.TestCase):
headers={'x-auth-token': 'secret'},
environ={'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_over_quota_container_create_still_works(self):
headers = [('x-account-bytes-used', '1001'),
@ -219,7 +219,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_CONTAINER_META_BERT': 'ernie',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_over_quota_container_post_still_works(self):
headers = [('x-account-bytes-used', '1001'),
@ -231,7 +231,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_CONTAINER_META_BERT': 'ernie',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_over_quota_obj_post_still_works(self):
headers = [('x-account-bytes-used', '1001'),
@ -243,7 +243,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_OBJECT_META_BERT': 'ernie',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_bytes_quota_copy_from(self):
headers = [('x-account-bytes-used', '500'),
@ -256,8 +256,8 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_bytes_quota_copy_verb(self):
headers = [('x-account-bytes-used', '500'),
@ -270,8 +270,8 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_not_exceed_bytes_quota_copy_from(self):
headers = [('x-account-bytes-used', '0'),
@ -284,7 +284,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_bytes_quota_copy_verb(self):
headers = [('x-account-bytes-used', '0'),
@ -297,7 +297,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_quota_copy_from_no_src(self):
headers = [('x-account-bytes-used', '0'),
@ -309,7 +309,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o3'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_quota_copy_from_bad_src(self):
headers = [('x-account-bytes-used', '0'),
@ -321,7 +321,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': 'bad_path'})
res = req.get_response(app)
self.assertEquals(res.status_int, 412)
self.assertEqual(res.status_int, 412)
def test_exceed_bytes_quota_reseller(self):
headers = [('x-account-bytes-used', '1000'),
@ -333,7 +333,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache,
'reseller_request': True})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_bytes_quota_reseller_copy_from(self):
headers = [('x-account-bytes-used', '500'),
@ -347,7 +347,7 @@ class TestAccountQuota(unittest.TestCase):
'reseller_request': True},
headers={'x-copy-from': 'c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_bytes_quota_reseller_copy_verb(self):
headers = [('x-account-bytes-used', '500'),
@ -361,7 +361,7 @@ class TestAccountQuota(unittest.TestCase):
'reseller_request': True},
headers={'Destination': 'c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_bad_application_quota(self):
headers = []
@ -371,7 +371,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 404)
self.assertEqual(res.status_int, 404)
def test_no_info_quota(self):
headers = []
@ -381,7 +381,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_bytes_quota(self):
headers = [('x-account-bytes-used', '1000'),
@ -392,7 +392,7 @@ class TestAccountQuota(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': cache})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_invalid_quotas(self):
headers = [('x-account-bytes-used', '0'), ]
@ -404,7 +404,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_ACCOUNT_META_QUOTA_BYTES': 'abc',
'reseller_request': True})
res = req.get_response(app)
self.assertEquals(res.status_int, 400)
self.assertEqual(res.status_int, 400)
def test_valid_quotas_admin(self):
headers = [('x-account-bytes-used', '0'), ]
@ -415,7 +415,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache,
'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 403)
self.assertEqual(res.status_int, 403)
def test_valid_quotas_reseller(self):
headers = [('x-account-bytes-used', '0'), ]
@ -427,7 +427,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '100',
'reseller_request': True})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_delete_quotas(self):
headers = [('x-account-bytes-used', '0'), ]
@ -438,7 +438,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache,
'HTTP_X_ACCOUNT_META_QUOTA_BYTES': ''})
res = req.get_response(app)
self.assertEquals(res.status_int, 403)
self.assertEqual(res.status_int, 403)
def test_delete_quotas_with_remove_header(self):
headers = [('x-account-bytes-used', '0'), ]
@ -449,7 +449,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache,
'HTTP_X_REMOVE_ACCOUNT_META_QUOTA_BYTES': 'True'})
res = req.get_response(app)
self.assertEquals(res.status_int, 403)
self.assertEqual(res.status_int, 403)
def test_delete_quotas_reseller(self):
headers = [('x-account-bytes-used', '0'), ]
@ -459,7 +459,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_ACCOUNT_META_QUOTA_BYTES': '',
'reseller_request': True})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_delete_quotas_with_remove_header_reseller(self):
headers = [('x-account-bytes-used', '0'), ]
@ -471,7 +471,7 @@ class TestAccountQuota(unittest.TestCase):
'HTTP_X_REMOVE_ACCOUNT_META_QUOTA_BYTES': 'True',
'reseller_request': True})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_invalid_request_exception(self):
headers = [('x-account-bytes-used', '1000'), ]
@ -482,7 +482,7 @@ class TestAccountQuota(unittest.TestCase):
'swift.cache': cache})
res = req.get_response(app)
# Response code of 200 because authentication itself is not done here
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
if __name__ == '__main__':

View File

@ -22,36 +22,36 @@ class TestACL(unittest.TestCase):
def test_clean_acl(self):
value = acl.clean_acl('header', '.r:*')
self.assertEquals(value, '.r:*')
self.assertEqual(value, '.r:*')
value = acl.clean_acl('header', '.r:specific.host')
self.assertEquals(value, '.r:specific.host')
self.assertEqual(value, '.r:specific.host')
value = acl.clean_acl('header', '.r:.ending.with')
self.assertEquals(value, '.r:.ending.with')
self.assertEqual(value, '.r:.ending.with')
value = acl.clean_acl('header', '.r:*.ending.with')
self.assertEquals(value, '.r:.ending.with')
self.assertEqual(value, '.r:.ending.with')
value = acl.clean_acl('header', '.r:-*.ending.with')
self.assertEquals(value, '.r:-.ending.with')
self.assertEqual(value, '.r:-.ending.with')
value = acl.clean_acl('header', '.r:one,.r:two')
self.assertEquals(value, '.r:one,.r:two')
self.assertEqual(value, '.r:one,.r:two')
value = acl.clean_acl('header', '.r:*,.r:-specific.host')
self.assertEquals(value, '.r:*,.r:-specific.host')
self.assertEqual(value, '.r:*,.r:-specific.host')
value = acl.clean_acl('header', '.r:*,.r:-.ending.with')
self.assertEquals(value, '.r:*,.r:-.ending.with')
self.assertEqual(value, '.r:*,.r:-.ending.with')
value = acl.clean_acl('header', '.r:one,.r:-two')
self.assertEquals(value, '.r:one,.r:-two')
self.assertEqual(value, '.r:one,.r:-two')
value = acl.clean_acl('header', '.r:one,.r:-two,account,account:user')
self.assertEquals(value, '.r:one,.r:-two,account,account:user')
self.assertEqual(value, '.r:one,.r:-two,account,account:user')
value = acl.clean_acl('header', 'TEST_account')
self.assertEquals(value, 'TEST_account')
self.assertEqual(value, 'TEST_account')
value = acl.clean_acl('header', '.ref:*')
self.assertEquals(value, '.r:*')
self.assertEqual(value, '.r:*')
value = acl.clean_acl('header', '.referer:*')
self.assertEquals(value, '.r:*')
self.assertEqual(value, '.r:*')
value = acl.clean_acl('header', '.referrer:*')
self.assertEquals(value, '.r:*')
self.assertEqual(value, '.r:*')
value = acl.clean_acl('header',
' .r : one , ,, .r:two , .r : - three ')
self.assertEquals(value, '.r:one,.r:two,.r:-three')
self.assertEqual(value, '.r:one,.r:two,.r:-three')
self.assertRaises(ValueError, acl.clean_acl, 'header', '.unknown:test')
self.assertRaises(ValueError, acl.clean_acl, 'header', '.r:')
self.assertRaises(ValueError, acl.clean_acl, 'header', '.r:*.')
@ -67,16 +67,16 @@ class TestACL(unittest.TestCase):
self.assertRaises(ValueError, acl.clean_acl, 'write-header', '.r:r')
def test_parse_acl(self):
self.assertEquals(acl.parse_acl(None), ([], []))
self.assertEquals(acl.parse_acl(''), ([], []))
self.assertEquals(acl.parse_acl('.r:ref1'), (['ref1'], []))
self.assertEquals(acl.parse_acl('.r:-ref1'), (['-ref1'], []))
self.assertEquals(acl.parse_acl('account:user'),
self.assertEqual(acl.parse_acl(None), ([], []))
self.assertEqual(acl.parse_acl(''), ([], []))
self.assertEqual(acl.parse_acl('.r:ref1'), (['ref1'], []))
self.assertEqual(acl.parse_acl('.r:-ref1'), (['-ref1'], []))
self.assertEqual(acl.parse_acl('account:user'),
([], ['account:user']))
self.assertEquals(acl.parse_acl('account'), ([], ['account']))
self.assertEquals(acl.parse_acl('acc1,acc2:usr2,.r:ref3,.r:-ref4'),
self.assertEqual(acl.parse_acl('account'), ([], ['account']))
self.assertEqual(acl.parse_acl('acc1,acc2:usr2,.r:ref3,.r:-ref4'),
(['ref3', '-ref4'], ['acc1', 'acc2:usr2']))
self.assertEquals(acl.parse_acl(
self.assertEqual(acl.parse_acl(
'acc1,acc2:usr2,.r:ref3,acc3,acc4:usr4,.r:ref5,.r:-ref6'),
(['ref3', 'ref5', '-ref6'],
['acc1', 'acc2:usr2', 'acc3', 'acc4:usr4']))
@ -105,7 +105,7 @@ class TestACL(unittest.TestCase):
for hdrs_in, expected in tests:
result = acl.parse_acl(version=2, data=hdrs_in.get('hdr'))
self.assertEquals(expected, result,
self.assertEqual(expected, result,
'%r: %r != %r' % (hdrs_in, result, expected))
def test_format_v1_acl(self):
@ -120,7 +120,7 @@ class TestACL(unittest.TestCase):
for (groups, refs), expected in tests:
result = acl.format_acl(
version=1, groups=groups, referrers=refs, header_name='hdr')
self.assertEquals(expected, result, 'groups=%r, refs=%r: %r != %r'
self.assertEqual(expected, result, 'groups=%r, refs=%r: %r != %r'
% (groups, refs, result, expected))
def test_format_v2_acl(self):
@ -133,7 +133,7 @@ class TestACL(unittest.TestCase):
for data, expected in tests:
result = acl.format_acl(version=2, acl_dict=data)
self.assertEquals(expected, result,
self.assertEqual(expected, result,
'data=%r: %r *!=* %r' % (data, result, expected))
def test_acls_from_account_info(self):

View File

@ -248,15 +248,15 @@ class TestUntar(unittest.TestCase):
def test_create_container_for_path(self):
req = Request.blank('/')
self.assertEquals(
self.assertEqual(
self.bulk.create_container(req, '/create_cont/acc/cont'),
True)
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
self.assertRaises(
bulk.CreateContainerError,
self.bulk.create_container,
req, '/create_cont_fail/acc/cont')
self.assertEquals(self.app.calls, 3)
self.assertEqual(self.app.calls, 3)
def test_extract_tar_works(self):
# On systems where $TMPDIR is long (like OS X), we need to do this
@ -289,7 +289,7 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, compress_format)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Files Created'], 6)
self.assertEqual(resp_data['Number Files Created'], 6)
# test out xml
req = Request.blank('/tar_works/acc/cont/')
@ -342,7 +342,7 @@ class TestUntar(unittest.TestCase):
req.environ['wsgi.input'] = open(
os.path.join(self.testdir, 'tar_works.tar.gz'))
self.bulk(req.environ, fake_start_response)
self.assertEquals(self.app.calls, 1)
self.assertEqual(self.app.calls, 1)
self.app.calls = 0
req.environ['wsgi.input'] = open(
@ -351,7 +351,7 @@ class TestUntar(unittest.TestCase):
req.method = 'PUT'
app_iter = self.bulk(req.environ, fake_start_response)
list(app_iter) # iter over resp
self.assertEquals(self.app.calls, 7)
self.assertEqual(self.app.calls, 7)
self.app.calls = 0
req = Request.blank('/tar_works/acc/cont/?extract-archive=bad')
@ -360,7 +360,7 @@ class TestUntar(unittest.TestCase):
req.environ['wsgi.input'] = open(
os.path.join(self.testdir, 'tar_works.tar.gz'))
t = self.bulk(req.environ, fake_start_response)
self.assertEquals(t[0], "Unsupported archive format")
self.assertEqual(t[0], "Unsupported archive format")
tar = tarfile.open(name=os.path.join(self.testdir,
'tar_works.tar'),
@ -375,7 +375,7 @@ class TestUntar(unittest.TestCase):
os.path.join(self.testdir, 'tar_works.tar'))
app_iter = self.bulk(req.environ, fake_start_response)
list(app_iter) # iter over resp
self.assertEquals(self.app.calls, 7)
self.assertEqual(self.app.calls, 7)
def test_bad_container(self):
req = Request.blank('/invalid/', body='')
@ -424,7 +424,7 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Files Created'], 4)
self.assertEqual(resp_data['Number Files Created'], 4)
def test_extract_tar_fail_cont_401(self):
self.build_tar()
@ -434,10 +434,10 @@ class TestUntar(unittest.TestCase):
'tar_fails.tar'))
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
self.assertEquals(self.app.calls, 1)
self.assertEqual(self.app.calls, 1)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '401 Unauthorized')
self.assertEquals(resp_data['Errors'], [])
self.assertEqual(resp_data['Response Status'], '401 Unauthorized')
self.assertEqual(resp_data['Errors'], [])
def test_extract_tar_fail_obj_401(self):
self.build_tar()
@ -447,10 +447,10 @@ class TestUntar(unittest.TestCase):
'tar_fails.tar'))
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '401 Unauthorized')
self.assertEquals(
self.assertEqual(resp_data['Response Status'], '401 Unauthorized')
self.assertEqual(
resp_data['Errors'],
[['cont/base_fails1/sub_dir1/sub1_file1', '401 Unauthorized']])
@ -462,10 +462,10 @@ class TestUntar(unittest.TestCase):
'tar_fails.tar'))
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
self.assertEquals(self.app.calls, 6)
self.assertEqual(self.app.calls, 6)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Files Created'], 4)
self.assertEquals(
self.assertEqual(resp_data['Number Files Created'], 4)
self.assertEqual(
resp_data['Errors'],
[['cont/base_fails1/' + ('f' * 101), '400 Bad Request']])
@ -477,10 +477,10 @@ class TestUntar(unittest.TestCase):
'tar_fails.tar'))
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, 'gz')
self.assertEquals(self.app.calls, 0)
self.assertEqual(self.app.calls, 0)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(
resp_data['Response Body'].lower(),
'invalid tar file: not a gzip file')
@ -494,10 +494,10 @@ class TestUntar(unittest.TestCase):
'tar_fails.tar'))
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
self.assertEquals(self.app.calls, 5)
self.assertEqual(self.app.calls, 5)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Files Created'], 3)
self.assertEquals(
self.assertEqual(resp_data['Number Files Created'], 3)
self.assertEqual(
resp_data['Errors'],
[['cont/base_fails1/' + ('f' * 101), '400 Bad Request']])
@ -519,7 +519,7 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
resp_data = utils.json.loads(resp_body)
self.assertEquals(
self.assertEqual(
resp_data['Errors'],
[['cont' + self.testdir + '/test/sub_dir1/sub1_file1',
'413 Request Entity Too Large']])
@ -537,10 +537,10 @@ class TestUntar(unittest.TestCase):
headers={'Accept': 'application/json'})
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
self.assertEquals(self.app.calls, 5)
self.assertEqual(self.app.calls, 5)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(
resp_data['Response Body'],
'More than 1 containers to create from tar.')
@ -557,8 +557,8 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
resp_data = utils.json.loads(resp_body)
self.assertEquals(self.app.calls, 5)
self.assertEquals(len(resp_data['Errors']), 5)
self.assertEqual(self.app.calls, 5)
self.assertEqual(len(resp_data['Errors']), 5)
def test_extract_tar_fail_create_cont_value_err(self):
self.build_tar()
@ -574,9 +574,9 @@ class TestUntar(unittest.TestCase):
with patch.object(self.bulk, 'create_container', bad_create):
resp_body = self.handle_extract_and_iter(req, '')
resp_data = utils.json.loads(resp_body)
self.assertEquals(self.app.calls, 0)
self.assertEquals(len(resp_data['Errors']), 5)
self.assertEquals(
self.assertEqual(self.app.calls, 0)
self.assertEqual(len(resp_data['Errors']), 5)
self.assertEqual(
resp_data['Errors'][0],
['cont/base_fails1/sub_dir1/sub1_file1', '400 Bad Request'])
@ -592,10 +592,10 @@ class TestUntar(unittest.TestCase):
req.headers['transfer-encoding'] = 'chunked'
resp_body = self.handle_extract_and_iter(req, '')
resp_data = utils.json.loads(resp_body)
self.assertEquals(self.app.calls, 4)
self.assertEquals(resp_data['Number Files Created'], 2)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(
self.assertEqual(self.app.calls, 4)
self.assertEqual(resp_data['Number Files Created'], 2)
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(
resp_data['Errors'],
[['sub_dir2/sub2%DEfile1', '412 Precondition Failed'],
['sub_%DEdir3/sub4_dir1/sub4_file1', '412 Precondition Failed']])
@ -636,15 +636,15 @@ class TestDelete(unittest.TestCase):
resp_body = ''.join(self.bulk.handle_delete_iter(
req, objs_to_delete=objs_to_delete,
out_content_type='application/json'))
self.assertEquals(
self.assertEqual(
self.app.delete_paths, ['/delete_works/AUTH_Acc/c/file_a',
'/delete_works/AUTH_Acc/c/file_d'])
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Number Deleted'], 2)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Number Deleted'], 2)
self.assertEqual(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Errors'],
[['/c/file_c', 'unauthorized']])
def test_bulk_delete_works_with_POST_verb(self):
@ -652,26 +652,26 @@ class TestDelete(unittest.TestCase):
headers={'Accept': 'application/json'})
req.method = 'POST'
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(
self.assertEqual(
self.app.delete_paths,
['/delete_works/AUTH_Acc/c/f', '/delete_works/AUTH_Acc/c/f404'])
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Number Deleted'], 1)
self.assertEqual(resp_data['Number Not Found'], 1)
def test_bulk_delete_works_with_DELETE_verb(self):
req = Request.blank('/delete_works/AUTH_Acc', body='/c/f\n/c/f404',
headers={'Accept': 'application/json'})
req.method = 'DELETE'
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(
self.assertEqual(
self.app.delete_paths,
['/delete_works/AUTH_Acc/c/f', '/delete_works/AUTH_Acc/c/f404'])
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Number Deleted'], 1)
self.assertEqual(resp_data['Number Not Found'], 1)
def test_bulk_delete_bad_content_type(self):
req = Request.blank('/delete_works/AUTH_Acc',
@ -684,11 +684,11 @@ class TestDelete(unittest.TestCase):
req.environ['wsgi.input'] = BytesIO(b'/c/f\n/c/f404')
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '406 Not Acceptable')
self.assertEqual(resp_data['Response Status'], '406 Not Acceptable')
def test_bulk_delete_call_and_content_type(self):
def fake_start_response(*args, **kwargs):
self.assertEquals(args[1][0], ('Content-Type', 'application/json'))
self.assertEqual(args[1][0], ('Content-Type', 'application/json'))
req = Request.blank('/delete_works/AUTH_Acc?bulk-delete')
req.method = 'POST'
@ -696,22 +696,22 @@ class TestDelete(unittest.TestCase):
req.headers['Accept'] = 'application/json'
req.environ['wsgi.input'] = BytesIO(b'/c/f%20')
list(self.bulk(req.environ, fake_start_response)) # iterate over resp
self.assertEquals(
self.assertEqual(
self.app.delete_paths, ['/delete_works/AUTH_Acc/c/f '])
self.assertEquals(self.app.calls, 1)
self.assertEqual(self.app.calls, 1)
def test_bulk_delete_get_objs(self):
req = Request.blank('/delete_works/AUTH_Acc', body='1%20\r\n2\r\n')
req.method = 'POST'
with patch.object(self.bulk, 'max_deletes_per_request', 2):
results = self.bulk.get_objs_to_delete(req)
self.assertEquals(results, [{'name': '1 '}, {'name': '2'}])
self.assertEqual(results, [{'name': '1 '}, {'name': '2'}])
with patch.object(self.bulk, 'max_path_length', 2):
results = []
req.environ['wsgi.input'] = BytesIO(b'1\n2\n3')
results = self.bulk.get_objs_to_delete(req)
self.assertEquals(results,
self.assertEqual(results,
[{'name': '1'}, {'name': '2'}, {'name': '3'}])
with patch.object(self.bulk, 'max_deletes_per_request', 9):
@ -727,15 +727,15 @@ class TestDelete(unittest.TestCase):
headers={'Accept': 'application/json'})
req.method = 'POST'
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(
self.assertEqual(
self.app.delete_paths,
['/delete_works/AUTH_Acc/c/f',
'/delete_works/AUTH_Acc/c/f404',
'/delete_works/AUTH_Acc/c/%25'])
self.assertEquals(self.app.calls, 3)
self.assertEqual(self.app.calls, 3)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 2)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Number Deleted'], 2)
self.assertEqual(resp_data['Number Not Found'], 1)
def test_bulk_delete_too_many_newlines(self):
req = Request.blank('/delete_works/AUTH_Acc')
@ -754,16 +754,16 @@ class TestDelete(unittest.TestCase):
headers={'Accept': 'application/json'})
req.method = 'POST'
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(
self.assertEqual(
self.app.delete_paths,
['/delete_works/AUTH_Acc/c/ obj \xe2\x99\xa1',
'/delete_works/AUTH_Acc/c/ objbadutf8'])
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(len(resp_data['Errors']), 2)
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Number Deleted'], 1)
self.assertEqual(len(resp_data['Errors']), 2)
self.assertEqual(resp_data['Errors'],
[[urllib.parse.quote('c/ objbadutf8'),
'412 Precondition Failed'],
[urllib.parse.quote('/c/f\xdebadutf8'),
@ -784,11 +784,11 @@ class TestDelete(unittest.TestCase):
headers={'Accept': 'application/json'})
req.method = 'POST'
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Errors'], [['/c/f', '401 Unauthorized']])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEqual(resp_data['Errors'], [['/c/f', '401 Unauthorized']])
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Number Deleted'], 1)
def test_bulk_delete_500_resp(self):
req = Request.blank('/broke/AUTH_acc/', body='/c/f\nc/f2\n',
@ -796,10 +796,10 @@ class TestDelete(unittest.TestCase):
req.method = 'POST'
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(
self.assertEqual(
resp_data['Errors'],
[['/c/f', '500 Internal Error'], ['c/f2', '500 Internal Error']])
self.assertEquals(resp_data['Response Status'], '502 Bad Gateway')
self.assertEqual(resp_data['Response Status'], '502 Bad Gateway')
def test_bulk_delete_bad_path(self):
req = Request.blank('/delete_cont_fail/')
@ -815,10 +815,10 @@ class TestDelete(unittest.TestCase):
return_value=None)) as mock_sleep:
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 0)
self.assertEquals(resp_data['Errors'], [['c', '409 Conflict']])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals([], mock_sleep.call_args_list)
self.assertEqual(resp_data['Number Deleted'], 0)
self.assertEqual(resp_data['Errors'], [['c', '409 Conflict']])
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual([], mock_sleep.call_args_list)
def test_bulk_delete_container_delete_retry_and_fails(self):
self.bulk.retry_count = 3
@ -830,10 +830,10 @@ class TestDelete(unittest.TestCase):
return_value=None)) as mock_sleep:
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 0)
self.assertEquals(resp_data['Errors'], [['c', '409 Conflict']])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals([call(self.bulk.retry_interval),
self.assertEqual(resp_data['Number Deleted'], 0)
self.assertEqual(resp_data['Errors'], [['c', '409 Conflict']])
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual([call(self.bulk.retry_interval),
call(self.bulk.retry_interval ** 2),
call(self.bulk.retry_interval ** 3)],
mock_sleep.call_args_list)
@ -849,10 +849,10 @@ class TestDelete(unittest.TestCase):
return_value=None)) as mock_sleep:
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 1)
self.assertEquals(resp_data['Errors'], [])
self.assertEquals(resp_data['Response Status'], '200 OK')
self.assertEquals([call(self.bulk.retry_interval),
self.assertEqual(resp_data['Number Deleted'], 1)
self.assertEqual(resp_data['Errors'], [])
self.assertEqual(resp_data['Response Status'], '200 OK')
self.assertEqual([call(self.bulk.retry_interval),
call(self.bulk.retry_interval ** 2)],
mock_sleep.call_args_list)
@ -866,9 +866,9 @@ class TestDelete(unittest.TestCase):
req.headers['Transfer-Encoding'] = 'chunked'
resp_body = self.handle_delete_and_iter(req)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Number Deleted'], 2)
self.assertEquals(resp_data['Errors'], [[bad_file, '400 Bad Request']])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Number Deleted'], 2)
self.assertEqual(resp_data['Errors'], [[bad_file, '400 Bad Request']])
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
def test_bulk_delete_bad_file_over_twice_max_length(self):
body = '/c/f\nc/' + ('123456' * self.bulk.max_path_length) + '\n'
@ -883,12 +883,12 @@ class TestDelete(unittest.TestCase):
req.method = 'POST'
with patch.object(self.bulk, 'max_failed_deletes', 2):
resp_body = self.handle_delete_and_iter(req)
self.assertEquals(self.app.calls, 2)
self.assertEqual(self.app.calls, 2)
resp_data = utils.json.loads(resp_body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Response Body'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Response Body'],
'Max delete failures exceeded')
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Errors'],
[['/c/f1', '401 Unauthorized'],
['/c/f2', '401 Unauthorized']])

View File

@ -55,12 +55,12 @@ class TestCNAMELookup(unittest.TestCase):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': '10.134.23.198'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'fc00:7ea1:f155::6321:8841'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_passthrough(self):
@ -71,16 +71,16 @@ class TestCNAMELookup(unittest.TestCase):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'foo.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'foo.example.com:8080'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'foo.example.com'},
headers={'Host': None})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_good_lookup(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
@ -91,16 +91,16 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'mysite.com:8080'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'mysite.com'},
headers={'Host': None})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_lookup_chain_too_long(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
@ -117,7 +117,7 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = self.app(req.environ, start_response)
self.assertEquals(resp, ['CNAME lookup failed after 2 tries'])
self.assertEqual(resp, ['CNAME lookup failed after 2 tries'])
def test_lookup_chain_bad_target(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
@ -128,7 +128,7 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = self.app(req.environ, start_response)
self.assertEquals(resp,
self.assertEqual(resp,
['CNAME lookup failed to resolve to a valid domain'])
def test_something_weird(self):
@ -140,7 +140,7 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = self.app(req.environ, start_response)
self.assertEquals(resp,
self.assertEqual(resp,
['CNAME lookup failed to resolve to a valid domain'])
def test_with_memcache(self):
@ -162,12 +162,12 @@ class TestCNAMELookup(unittest.TestCase):
'swift.cache': memcache},
headers={'Host': 'mysite.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
'swift.cache': memcache},
headers={'Host': 'mysite.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_cname_matching_ending_not_domain(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
@ -178,7 +178,7 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = self.app(req.environ, start_response)
self.assertEquals(resp,
self.assertEqual(resp,
['CNAME lookup failed to resolve to a valid domain'])
def test_cname_configured_with_empty_storage_domain(self):
@ -193,28 +193,28 @@ class TestCNAMELookup(unittest.TestCase):
cname_lookup.lookup_cname = my_lookup
resp = app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_storage_domains_conf_format(self):
conf = {'storage_domain': 'foo.com'}
app = cname_lookup.filter_factory(conf)(FakeApp())
self.assertEquals(app.storage_domain, ['.foo.com'])
self.assertEqual(app.storage_domain, ['.foo.com'])
conf = {'storage_domain': 'foo.com, '}
app = cname_lookup.filter_factory(conf)(FakeApp())
self.assertEquals(app.storage_domain, ['.foo.com'])
self.assertEqual(app.storage_domain, ['.foo.com'])
conf = {'storage_domain': 'foo.com, bar.com'}
app = cname_lookup.filter_factory(conf)(FakeApp())
self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com'])
self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com'])
conf = {'storage_domain': 'foo.com, .bar.com'}
app = cname_lookup.filter_factory(conf)(FakeApp())
self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com'])
self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com'])
conf = {'storage_domain': '.foo.com, .bar.com'}
app = cname_lookup.filter_factory(conf)(FakeApp())
self.assertEquals(app.storage_domain, ['.foo.com', '.bar.com'])
self.assertEqual(app.storage_domain, ['.foo.com', '.bar.com'])
def test_multiple_storage_domains(self):
conf = {'storage_domain': 'storage1.com, storage2.com',
@ -229,11 +229,11 @@ class TestCNAMELookup(unittest.TestCase):
return app(req.environ, start_response)
resp = do_test('c.storage1.com')
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
resp = do_test('c.storage2.com')
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
bad_domain = ['CNAME lookup failed to resolve to a valid domain']
resp = do_test('c.badtest.com')
self.assertEquals(resp, bad_domain)
self.assertEqual(resp, bad_domain)

View File

@ -47,7 +47,7 @@ class TestCrossDomain(unittest.TestCase):
req = Request.blank('/crossdomain.xml',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, [expectedResponse])
self.assertEqual(resp, [expectedResponse])
# GET of /crossdomain.xml (custom)
def test_crossdomain_custom(self):
@ -64,13 +64,13 @@ class TestCrossDomain(unittest.TestCase):
req = Request.blank('/crossdomain.xml',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, [expectedResponse])
self.assertEqual(resp, [expectedResponse])
# GET to a different resource should be passed on
def test_crossdomain_pass(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
# Only GET is allowed on the /crossdomain.xml resource
def test_crossdomain_get_only(self):
@ -78,7 +78,7 @@ class TestCrossDomain(unittest.TestCase):
req = Request.blank('/crossdomain.xml',
environ={'REQUEST_METHOD': method})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
if __name__ == '__main__':

View File

@ -40,72 +40,72 @@ class TestDomainRemap(unittest.TestCase):
'SERVER_NAME': 'example.com'},
headers={'Host': None})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/')
self.assertEqual(resp, '/')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/')
self.assertEqual(resp, '/')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'example.com:8080'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/')
self.assertEqual(resp, '/')
def test_domain_remap_account(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'AUTH_a.example.com'},
headers={'Host': None})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a')
self.assertEqual(resp, '/v1/AUTH_a')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a')
self.assertEqual(resp, '/v1/AUTH_a')
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'AUTH-uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_uuid')
self.assertEqual(resp, '/v1/AUTH_uuid')
def test_domain_remap_account_container(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a/c')
self.assertEqual(resp, '/v1/AUTH_a/c')
def test_domain_remap_extra_subdomains(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'x.y.c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, ['Bad domain in host header'])
self.assertEqual(resp, ['Bad domain in host header'])
def test_domain_remap_account_with_path_root(self):
req = Request.blank('/v1', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a')
self.assertEqual(resp, '/v1/AUTH_a')
def test_domain_remap_account_container_with_path_root(self):
req = Request.blank('/v1', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a/c')
self.assertEqual(resp, '/v1/AUTH_a/c')
def test_domain_remap_account_container_with_path(self):
req = Request.blank('/obj', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a/c/obj')
self.assertEqual(resp, '/v1/AUTH_a/c/obj')
def test_domain_remap_account_container_with_path_root_and_path(self):
req = Request.blank('/v1/obj', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_a/c/obj')
self.assertEqual(resp, '/v1/AUTH_a/c/obj')
def test_domain_remap_account_matching_ending_not_domain(self):
req = Request.blank('/dontchange', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.aexample.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/dontchange')
self.assertEqual(resp, '/dontchange')
def test_domain_remap_configured_with_empty_storage_domain(self):
self.app = domain_remap.DomainRemapMiddleware(FakeApp(),
@ -113,7 +113,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.AUTH_a.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/test')
self.assertEqual(resp, '/test')
def test_domain_remap_configured_with_prefixes(self):
conf = {'reseller_prefixes': 'PREFIX'}
@ -121,7 +121,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.prefix_uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/PREFIX_uuid/c/test')
self.assertEqual(resp, '/v1/PREFIX_uuid/c/test')
def test_domain_remap_configured_with_bad_prefixes(self):
conf = {'reseller_prefixes': 'UNKNOWN'}
@ -129,7 +129,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.prefix_uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/test')
self.assertEqual(resp, '/test')
def test_domain_remap_configured_with_no_prefixes(self):
conf = {'reseller_prefixes': ''}
@ -137,7 +137,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'c.uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/uuid/c/test')
self.assertEqual(resp, '/v1/uuid/c/test')
def test_domain_remap_add_prefix(self):
conf = {'default_reseller_prefix': 'FOO'}
@ -145,7 +145,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/FOO_uuid/test')
self.assertEqual(resp, '/v1/FOO_uuid/test')
def test_domain_remap_add_prefix_already_there(self):
conf = {'default_reseller_prefix': 'AUTH'}
@ -153,7 +153,7 @@ class TestDomainRemap(unittest.TestCase):
req = Request.blank('/test', environ={'REQUEST_METHOD': 'GET'},
headers={'Host': 'auth-uuid.example.com'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, '/v1/AUTH_uuid/test')
self.assertEqual(resp, '/v1/AUTH_uuid/test')
class TestSwiftInfo(unittest.TestCase):
@ -172,7 +172,7 @@ class TestSwiftInfo(unittest.TestCase):
domain_remap.filter_factory({'default_reseller_prefix': 'cupcake'})
swift_info = utils.get_swift_info()
self.assertTrue('domain_remap' in swift_info)
self.assertEquals(
self.assertEqual(
swift_info['domain_remap'].get('default_reseller_prefix'),
'cupcake')

View File

@ -57,43 +57,43 @@ class TestCatchErrors(unittest.TestCase):
app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(list(resp), ['FAKE APP'])
self.assertEqual(list(resp), ['FAKE APP'])
def test_catcherrors(self):
app = catch_errors.CatchErrorMiddleware(FakeApp(True), {})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(list(resp), ['An error occurred'])
self.assertEqual(list(resp), ['An error occurred'])
def test_trans_id_header_pass(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(FakeApp(), {})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
self.assertEquals(len(self.logger.txn_id), 34) # 32 hex + 'tx'
self.assertEqual(len(self.logger.txn_id), 34) # 32 hex + 'tx'
def test_trans_id_header_fail(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
app = catch_errors.CatchErrorMiddleware(FakeApp(True), {})
req = Request.blank('/v1/a/c/o')
app(req.environ, start_response)
self.assertEquals(len(self.logger.txn_id), 34)
self.assertEqual(len(self.logger.txn_id), 34)
def test_error_in_iterator(self):
app = catch_errors.CatchErrorMiddleware(
FakeApp(body_iter=(int(x) for x in 'abcd')), {})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(list(resp), ['An error occurred'])
self.assertEqual(list(resp), ['An error occurred'])
def test_trans_id_header_suffix(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
@ -104,7 +104,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertTrue(self.logger.txn_id.endswith('-stuff'))
def test_trans_id_header_extra(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
@ -116,7 +116,7 @@ class TestCatchErrors(unittest.TestCase):
self.assertTrue(self.logger.txn_id.endswith('-fromconf-fromuser'))
def test_trans_id_header_extra_length_limit(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
@ -129,7 +129,7 @@ class TestCatchErrors(unittest.TestCase):
'-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))
def test_trans_id_header_extra_quoted(self):
self.assertEquals(self.logger.txn_id, None)
self.assertEqual(self.logger.txn_id, None)
def start_response(status, headers, exc_info=None):
self.assertTrue('X-Trans-Id' in (x[0] for x in headers))
@ -143,7 +143,7 @@ class TestCatchErrors(unittest.TestCase):
app = catch_errors.CatchErrorMiddleware(FakeApp(error='strange'), {})
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = app(req.environ, start_response)
self.assertEquals(list(resp), ['An error occurred'])
self.assertEqual(list(resp), ['An error occurred'])
if __name__ == '__main__':

View File

@ -73,7 +73,7 @@ class FakeApp(object):
class TestCappedFileLikeObject(unittest.TestCase):
def test_whole(self):
self.assertEquals(
self.assertEqual(
formpost._CappedFileLikeObject(BytesIO(b'abc'), 10).read(),
b'abc')
@ -83,31 +83,31 @@ class TestCappedFileLikeObject(unittest.TestCase):
formpost._CappedFileLikeObject(BytesIO(b'abc'), 2).read()
except EOFError as err:
exc = err
self.assertEquals(str(exc), 'max_file_size exceeded')
self.assertEqual(str(exc), 'max_file_size exceeded')
def test_whole_readline(self):
fp = formpost._CappedFileLikeObject(BytesIO(b'abc\ndef'), 10)
self.assertEquals(fp.readline(), b'abc\n')
self.assertEquals(fp.readline(), b'def')
self.assertEquals(fp.readline(), b'')
self.assertEqual(fp.readline(), b'abc\n')
self.assertEqual(fp.readline(), b'def')
self.assertEqual(fp.readline(), b'')
def test_exceeded_readline(self):
fp = formpost._CappedFileLikeObject(BytesIO(b'abc\ndef'), 5)
self.assertEquals(fp.readline(), b'abc\n')
self.assertEqual(fp.readline(), b'abc\n')
exc = None
try:
self.assertEquals(fp.readline(), b'def')
self.assertEqual(fp.readline(), b'def')
except EOFError as err:
exc = err
self.assertEquals(str(exc), 'max_file_size exceeded')
self.assertEqual(str(exc), 'max_file_size exceeded')
def test_read_sized(self):
fp = formpost._CappedFileLikeObject(BytesIO(b'abcdefg'), 10)
self.assertEquals(fp.read(2), b'ab')
self.assertEquals(fp.read(2), b'cd')
self.assertEquals(fp.read(2), b'ef')
self.assertEquals(fp.read(2), b'g')
self.assertEquals(fp.read(2), b'')
self.assertEqual(fp.read(2), b'ab')
self.assertEqual(fp.read(2), b'cd')
self.assertEqual(fp.read(2), b'ef')
self.assertEqual(fp.read(2), b'g')
self.assertEqual(fp.read(2), b'')
class TestFormPost(unittest.TestCase):
@ -238,7 +238,7 @@ class TestFormPost(unittest.TestCase):
resp = self._make_request(
'/v1/a/c/o',
environ={'REQUEST_METHOD': method}).get_response(self.formpost)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('FormPost' not in resp.body)
def test_auth_scheme(self):
@ -266,13 +266,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
authenticate_v = None
for h, v in headers:
if h.lower() == 'www-authenticate':
authenticate_v = v
self.assertTrue('FormPost: Form Expired' in body)
self.assertEquals('Swift realm="unknown"', authenticate_v)
self.assertEqual('Swift realm="unknown"', authenticate_v)
def test_safari(self):
key = 'abc'
@ -379,17 +379,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://brim.net?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://brim.net?status=201&message=')
self.assertEqual(exc_info, None)
self.assertTrue('http://brim.net?status=201&message=' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_firefox(self):
key = 'abc'
@ -495,17 +495,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://brim.net?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://brim.net?status=201&message=')
self.assertEqual(exc_info, None)
self.assertTrue('http://brim.net?status=201&message=' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_chrome(self):
key = 'abc'
@ -614,17 +614,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://brim.net?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://brim.net?status=201&message=')
self.assertEqual(exc_info, None)
self.assertTrue('http://brim.net?status=201&message=' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_explorer(self):
key = 'abc'
@ -729,17 +729,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://brim.net?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://brim.net?status=201&message=')
self.assertEqual(exc_info, None)
self.assertTrue('http://brim.net?status=201&message=' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_messed_up_start(self):
key = 'abc'
@ -772,10 +772,10 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEquals(exc_info, None)
self.assertEqual(status, '400 Bad Request')
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: invalid starting boundary' in body)
self.assertEquals(len(self.app.requests), 0)
self.assertEqual(len(self.app.requests), 0)
def test_max_file_size_exceeded(self):
key = 'abc'
@ -803,10 +803,10 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEquals(exc_info, None)
self.assertEqual(status, '400 Bad Request')
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: max_file_size exceeded' in body)
self.assertEquals(len(self.app.requests), 0)
self.assertEqual(len(self.app.requests), 0)
def test_max_file_count_exceeded(self):
key = 'abc'
@ -834,20 +834,20 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(
self.assertEqual(
location,
'http://brim.net?status=400&message=max%20file%20count%20exceeded')
self.assertEquals(exc_info, None)
self.assertEqual(exc_info, None)
self.assertTrue(
'http://brim.net?status=400&message=max%20file%20count%20exceeded'
in body)
self.assertEquals(len(self.app.requests), 1)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(len(self.app.requests), 1)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
def test_subrequest_does_not_pass_query(self):
key = 'abc'
@ -879,10 +879,10 @@ class TestFormPost(unittest.TestCase):
exc_info = exc_info[0]
# Make sure we 201 Created, which means we made the final subrequest
# (and FakeApp verifies that no QUERY_STRING got passed).
self.assertEquals(status, '201 Created')
self.assertEquals(exc_info, None)
self.assertEqual(status, '201 Created')
self.assertEqual(exc_info, None)
self.assertTrue('201 Created' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEqual(len(self.app.requests), 2)
def test_subrequest_fails(self):
key = 'abc'
@ -910,15 +910,15 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://brim.net?status=404&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://brim.net?status=404&message=')
self.assertEqual(exc_info, None)
self.assertTrue('http://brim.net?status=404&message=' in body)
self.assertEquals(len(self.app.requests), 1)
self.assertEqual(len(self.app.requests), 1)
def test_truncated_attr_value(self):
key = 'abc'
@ -996,20 +996,20 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(
self.assertEqual(
location,
('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(exc_info, None)
self.assertTrue(
('a' * formpost.MAX_VALUE_LENGTH) + '?status=201&message=' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_no_file_to_process(self):
key = 'abc'
@ -1067,19 +1067,19 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(
self.assertEqual(
location,
'http://brim.net?status=400&message=no%20files%20to%20process')
self.assertEquals(exc_info, None)
self.assertEqual(exc_info, None)
self.assertTrue(
'http://brim.net?status=400&message=no%20files%20to%20process'
in body)
self.assertEquals(len(self.app.requests), 0)
self.assertEqual(len(self.app.requests), 0)
def test_formpost_without_useragent(self):
key = 'abc'
@ -1099,7 +1099,7 @@ class TestFormPost(unittest.TestCase):
pass
body = ''.join(self.formpost(env, start_response))
self.assertTrue('User-Agent' in self.app.requests[0].headers)
self.assertEquals(self.app.requests[0].headers['User-Agent'],
self.assertEqual(self.app.requests[0].headers['User-Agent'],
'FormPost')
def test_formpost_with_origin(self):
@ -1127,7 +1127,7 @@ class TestFormPost(unittest.TestCase):
pass
body = ''.join(self.formpost(env, start_response))
self.assertEquals(headers['Access-Control-Allow-Origin'],
self.assertEqual(headers['Access-Control-Allow-Origin'],
'http://localhost:5000')
def test_formpost_with_multiple_keys(self):
@ -1219,17 +1219,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, 'http://redirect?status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(location, 'http://redirect?status=201&message=')
self.assertEqual(exc_info, None)
self.assertTrue(location in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_redirect_with_query(self):
key = 'abc'
@ -1257,18 +1257,18 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '303 See Other')
self.assertEqual(status, '303 See Other')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location,
self.assertEqual(location,
'http://redirect?one=two&status=201&message=')
self.assertEquals(exc_info, None)
self.assertEqual(exc_info, None)
self.assertTrue(location in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_no_redirect(self):
key = 'abc'
@ -1295,17 +1295,17 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '201 Created')
self.assertEqual(status, '201 Created')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('201 Created' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEquals(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEquals(self.app.requests[1].body, 'Test\nFile\nTwo\n')
self.assertEqual(len(self.app.requests), 2)
self.assertEqual(self.app.requests[0].body, 'Test File\nOne\n')
self.assertEqual(self.app.requests[1].body, 'Test\nFile\nTwo\n')
def test_no_redirect_expired(self):
key = 'abc'
@ -1331,13 +1331,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Form Expired' in body)
def test_no_redirect_invalid_sig(self):
@ -1365,13 +1365,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_no_redirect_with_error(self):
@ -1398,13 +1398,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEqual(status, '400 Bad Request')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: invalid starting boundary' in body)
def test_no_v1(self):
@ -1431,13 +1431,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_empty_v1(self):
@ -1464,13 +1464,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_empty_account(self):
@ -1497,13 +1497,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_wrong_account(self):
@ -1532,13 +1532,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_no_container(self):
@ -1565,13 +1565,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '401 Unauthorized')
self.assertEqual(status, '401 Unauthorized')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: Invalid Signature' in body)
def test_completely_non_int_expires(self):
@ -1603,13 +1603,13 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEqual(status, '400 Bad Request')
location = None
for h, v in headers:
if h.lower() == 'location':
location = v
self.assertEquals(location, None)
self.assertEquals(exc_info, None)
self.assertEqual(location, None)
self.assertEqual(exc_info, None)
self.assertTrue('FormPost: expired not an integer' in body)
def test_x_delete_at(self):
@ -1645,14 +1645,14 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '201 Created')
self.assertEqual(status, '201 Created')
self.assertTrue('201 Created' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEqual(len(self.app.requests), 2)
self.assertTrue("X-Delete-At" in self.app.requests[0].headers)
self.assertTrue("X-Delete-At" in self.app.requests[1].headers)
self.assertEquals(delete_at,
self.assertEqual(delete_at,
self.app.requests[0].headers["X-Delete-At"])
self.assertEquals(delete_at,
self.assertEqual(delete_at,
self.app.requests[1].headers["X-Delete-At"])
def test_x_delete_at_not_int(self):
@ -1687,7 +1687,7 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEqual(status, '400 Bad Request')
self.assertTrue('FormPost: x_delete_at not an integer' in body)
def test_x_delete_after(self):
@ -1723,9 +1723,9 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '201 Created')
self.assertEqual(status, '201 Created')
self.assertTrue('201 Created' in body)
self.assertEquals(len(self.app.requests), 2)
self.assertEqual(len(self.app.requests), 2)
self.assertTrue("X-Delete-After" in self.app.requests[0].headers)
self.assertTrue("X-Delete-After" in self.app.requests[1].headers)
self.assertEqual(delete_after,
@ -1765,7 +1765,7 @@ class TestFormPost(unittest.TestCase):
status = status[0]
headers = headers[0]
exc_info = exc_info[0]
self.assertEquals(status, '400 Bad Request')
self.assertEqual(status, '400 Bad Request')
self.assertTrue('FormPost: x_delete_after not an integer' in body)

View File

@ -99,8 +99,8 @@ class TestGatekeeper(unittest.TestCase):
fake_app = FakeApp()
app = self.get_app(fake_app, {})
resp = req.get_response(app)
self.assertEquals('200 OK', resp.status)
self.assertEquals(resp.body, 'FAKE APP')
self.assertEqual('200 OK', resp.status)
self.assertEqual(resp.body, 'FAKE APP')
self._assertHeadersEqual(self.allowed_headers, fake_app.req.headers)
def _test_reserved_header_removed_inbound(self, method):
@ -111,7 +111,7 @@ class TestGatekeeper(unittest.TestCase):
fake_app = FakeApp()
app = self.get_app(fake_app, {})
resp = req.get_response(app)
self.assertEquals('200 OK', resp.status)
self.assertEqual('200 OK', resp.status)
self._assertHeadersEqual(self.allowed_headers, fake_app.req.headers)
self._assertHeadersAbsent(self.forbidden_headers_in,
fake_app.req.headers)
@ -127,7 +127,7 @@ class TestGatekeeper(unittest.TestCase):
fake_app = FakeApp(headers=headers)
app = self.get_app(fake_app, {})
resp = req.get_response(app)
self.assertEquals('200 OK', resp.status)
self.assertEqual('200 OK', resp.status)
self._assertHeadersEqual(self.allowed_headers, resp.headers)
self._assertHeadersAbsent(self.forbidden_headers_out, resp.headers)

View File

@ -50,30 +50,30 @@ class TestHealthCheck(unittest.TestCase):
req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'})
app = self.get_app(FakeApp(), {})
resp = app(req.environ, self.start_response)
self.assertEquals(['200 OK'], self.got_statuses)
self.assertEquals(resp, ['OK'])
self.assertEqual(['200 OK'], self.got_statuses)
self.assertEqual(resp, ['OK'])
def test_healtcheck_pass(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
app = self.get_app(FakeApp(), {})
resp = app(req.environ, self.start_response)
self.assertEquals(['200 OK'], self.got_statuses)
self.assertEquals(resp, ['FAKE APP'])
self.assertEqual(['200 OK'], self.got_statuses)
self.assertEqual(resp, ['FAKE APP'])
def test_healthcheck_pass_not_disabled(self):
req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'})
app = self.get_app(FakeApp(), {}, disable_path=self.disable_path)
resp = app(req.environ, self.start_response)
self.assertEquals(['200 OK'], self.got_statuses)
self.assertEquals(resp, ['OK'])
self.assertEqual(['200 OK'], self.got_statuses)
self.assertEqual(resp, ['OK'])
def test_healthcheck_pass_disabled(self):
open(self.disable_path, 'w')
req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'})
app = self.get_app(FakeApp(), {}, disable_path=self.disable_path)
resp = app(req.environ, self.start_response)
self.assertEquals(['503 Service Unavailable'], self.got_statuses)
self.assertEquals(resp, ['DISABLED BY FILE'])
self.assertEqual(['503 Service Unavailable'], self.got_statuses)
self.assertEqual(resp, ['DISABLED BY FILE'])
if __name__ == '__main__':

View File

@ -205,7 +205,7 @@ class SwiftAuth(unittest.TestCase):
req = self._make_request('/v1/AUTH_account',
environ={'swift.authorize_override': True})
resp = req.get_response(self.test_auth)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
def test_override_asked_for_and_allowed(self):
conf = {'allow_overrides': 'true'}
@ -213,13 +213,13 @@ class SwiftAuth(unittest.TestCase):
req = self._make_request('/v1/AUTH_account',
environ={'swift.authorize_override': True})
resp = req.get_response(self.test_auth)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_override_default_allowed(self):
req = self._make_request('/v1/AUTH_account',
environ={'swift.authorize_override': True})
resp = req.get_response(self.test_auth)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_anonymous_options_allowed(self):
req = self._make_request('/v1/AUTH_account',
@ -611,7 +611,7 @@ class TestAuthorize(BaseTestAuthorize):
if exception and not result:
self.fail("error %s was not returned" % (str(exception)))
elif exception:
self.assertEquals(result.status_int, exception)
self.assertEqual(result.status_int, exception)
else:
self.assertTrue(result is None)
return req
@ -928,7 +928,7 @@ class TestAuthorize(BaseTestAuthorize):
'roles': list(roles)}
data = self.test_auth._keystone_identity(req.environ)
self.assertEquals(expected, data)
self.assertEqual(expected, data)
def test_integral_keystone_identity(self):
user = ('U_ID', 'U_NAME')
@ -967,7 +967,7 @@ class TestAuthorize(BaseTestAuthorize):
'project_domain': (None, None),
'auth_version': 0}
data = self.test_auth._integral_keystone_identity(req.environ)
self.assertEquals(expected, data)
self.assertEqual(expected, data)
# v2 token info in environ
req.environ['keystone.token_info'] = _fake_token_info(version='2')
@ -979,7 +979,7 @@ class TestAuthorize(BaseTestAuthorize):
'project_domain': (None, None),
'auth_version': 2}
data = self.test_auth._integral_keystone_identity(req.environ)
self.assertEquals(expected, data)
self.assertEqual(expected, data)
# v3 token info in environ
req.environ['keystone.token_info'] = _fake_token_info(version='3')
@ -991,7 +991,7 @@ class TestAuthorize(BaseTestAuthorize):
'project_domain': project_domain,
'auth_version': 3}
data = self.test_auth._integral_keystone_identity(req.environ)
self.assertEquals(expected, data)
self.assertEqual(expected, data)
# service token in environ
req.headers.update({'X-Service-Roles': '%s,%s' % service_roles})
@ -1003,7 +1003,7 @@ class TestAuthorize(BaseTestAuthorize):
'project_domain': project_domain,
'auth_version': 3}
data = self.test_auth._integral_keystone_identity(req.environ)
self.assertEquals(expected, data)
self.assertEqual(expected, data)
def test_get_project_domain_id(self):
sysmeta = {}

View File

@ -112,7 +112,7 @@ class TestListEndpoints(unittest.TestCase):
info['storage_policy'] = self.policy_to_test
(version, account, container, unused) = \
split_path(env['PATH_INFO'], 3, 4, True)
self.assertEquals((version, account, container),
self.assertEqual((version, account, container),
self.expected_path[:3])
return info
@ -194,9 +194,9 @@ class TestListEndpoints(unittest.TestCase):
self.assertEqual(obj, None)
def test_get_object_ring(self):
self.assertEquals(isinstance(self.list_endpoints.get_object_ring(0),
self.assertEqual(isinstance(self.list_endpoints.get_object_ring(0),
ring.Ring), True)
self.assertEquals(isinstance(self.list_endpoints.get_object_ring(1),
self.assertEqual(isinstance(self.list_endpoints.get_object_ring(1),
ring.Ring), True)
self.assertRaises(ValueError, self.list_endpoints.get_object_ring, 99)
@ -238,9 +238,9 @@ class TestListEndpoints(unittest.TestCase):
# ring.get_nodes().
resp = Request.blank('/endpoints/a/c/o1').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sdb1/1/a/c/o1",
"http://10.1.2.2:6000/sdd1/1/a/c/o1"
])
@ -258,31 +258,31 @@ class TestListEndpoints(unittest.TestCase):
with mock.patch(PATCHGI, self.FakeGetInfo):
resp = Request.blank('/endpoints/a/c/o1').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(json.loads(resp.body), expected[pol.idx])
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(json.loads(resp.body), expected[pol.idx])
# Here, 'o1/' is the object name.
resp = Request.blank('/endpoints/a/c/o1/').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sdb1/3/a/c/o1/",
"http://10.1.2.2:6000/sdd1/3/a/c/o1/"
])
resp = Request.blank('/endpoints/a/c2').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sda1/2/a/c2",
"http://10.1.2.1:6000/sdc1/2/a/c2"
])
resp = Request.blank('/endpoints/a1').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.2.1:6000/sdc1/0/a1",
"http://10.1.1.1:6000/sda1/0/a1",
"http://10.1.1.1:6000/sdb1/0/a1"
@ -290,43 +290,43 @@ class TestListEndpoints(unittest.TestCase):
resp = Request.blank('/endpoints/').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
resp = Request.blank('/endpoints/a/c 2').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sdb1/3/a/c%202",
"http://10.1.2.2:6000/sdd1/3/a/c%202"
])
resp = Request.blank('/endpoints/a/c%202').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sdb1/3/a/c%202",
"http://10.1.2.2:6000/sdd1/3/a/c%202"
])
resp = Request.blank('/endpoints/ac%20count/con%20tainer/ob%20ject') \
.get_response(self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(json.loads(resp.body), [
self.assertEqual(resp.status_int, 200)
self.assertEqual(json.loads(resp.body), [
"http://10.1.1.1:6000/sdb1/3/ac%20count/con%20tainer/ob%20ject",
"http://10.1.2.2:6000/sdd1/3/ac%20count/con%20tainer/ob%20ject"
])
resp = Request.blank('/endpoints/a/c/o1', {'REQUEST_METHOD': 'POST'}) \
.get_response(self.list_endpoints)
self.assertEquals(resp.status_int, 405)
self.assertEquals(resp.status, '405 Method Not Allowed')
self.assertEquals(resp.headers['allow'], 'GET')
self.assertEqual(resp.status_int, 405)
self.assertEqual(resp.status, '405 Method Not Allowed')
self.assertEqual(resp.headers['allow'], 'GET')
resp = Request.blank('/not-endpoints').get_response(
self.list_endpoints)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.status, '200 OK')
self.assertEquals(resp.body, 'FakeApp')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.status, '200 OK')
self.assertEqual(resp.body, 'FakeApp')
# test policies with custom endpoint name
for pol in POLICIES:
@ -339,9 +339,9 @@ class TestListEndpoints(unittest.TestCase):
with mock.patch(PATCHGI, self.FakeGetInfo):
resp = Request.blank('/some/another/path/a/c/o1') \
.get_response(custom_path_le)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(json.loads(resp.body), expected[pol.idx])
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(json.loads(resp.body), expected[pol.idx])
# test custom path without trailing slash
custom_path_le = list_endpoints.filter_factory({
@ -352,9 +352,9 @@ class TestListEndpoints(unittest.TestCase):
with mock.patch(PATCHGI, self.FakeGetInfo):
resp = Request.blank('/some/another/path/a/c/o1') \
.get_response(custom_path_le)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(json.loads(resp.body), expected[pol.idx])
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(json.loads(resp.body), expected[pol.idx])
def test_v1_response(self):
req = Request.blank('/endpoints/v1/a/c/o1')

View File

@ -126,13 +126,13 @@ class TestCacheMiddleware(unittest.TestCase):
try:
memcache.MemcacheMiddleware(FakeApp(), d)
except Exception as err:
self.assertEquals(
self.assertEqual(
str(err),
"read called with '/etc/swift/memcache.conf'")
count += 1
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(count, 7)
self.assertEqual(count, 7)
def test_conf_set_no_read(self):
orig_parser = memcache.ConfigParser
@ -147,7 +147,7 @@ class TestCacheMiddleware(unittest.TestCase):
exc = err
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(exc, None)
self.assertEqual(exc, None)
def test_conf_default(self):
orig_parser = memcache.ConfigParser
@ -156,10 +156,10 @@ class TestCacheMiddleware(unittest.TestCase):
app = memcache.MemcacheMiddleware(FakeApp(), {})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '127.0.0.1:11211')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, False)
self.assertEquals(
self.assertEqual(app.memcache_servers, '127.0.0.1:11211')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, False)
self.assertEqual(
app.memcache._client_cache['127.0.0.1:11211'].max_size, 2)
def test_conf_inline(self):
@ -173,10 +173,10 @@ class TestCacheMiddleware(unittest.TestCase):
'memcache_max_connections': '5'})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
self.assertEquals(app.memcache._allow_pickle, True)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '6.7.8.9:10')
self.assertEqual(app.memcache._allow_pickle, True)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['6.7.8.9:10'].max_size, 5)
def test_conf_extra_no_section(self):
@ -186,10 +186,10 @@ class TestCacheMiddleware(unittest.TestCase):
app = memcache.MemcacheMiddleware(FakeApp(), {})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '127.0.0.1:11211')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, False)
self.assertEquals(
self.assertEqual(app.memcache_servers, '127.0.0.1:11211')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, False)
self.assertEqual(
app.memcache._client_cache['127.0.0.1:11211'].max_size, 2)
def test_conf_extra_no_option(self):
@ -201,10 +201,10 @@ class TestCacheMiddleware(unittest.TestCase):
app = memcache.MemcacheMiddleware(FakeApp(), {})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '127.0.0.1:11211')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, False)
self.assertEquals(
self.assertEqual(app.memcache_servers, '127.0.0.1:11211')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, False)
self.assertEqual(
app.memcache._client_cache['127.0.0.1:11211'].max_size, 2)
def test_conf_inline_other_max_conn(self):
@ -218,10 +218,10 @@ class TestCacheMiddleware(unittest.TestCase):
'max_connections': '5'})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
self.assertEquals(app.memcache._allow_pickle, True)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '6.7.8.9:10')
self.assertEqual(app.memcache._allow_pickle, True)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['6.7.8.9:10'].max_size, 5)
def test_conf_inline_bad_max_conn(self):
@ -235,10 +235,10 @@ class TestCacheMiddleware(unittest.TestCase):
'max_connections': 'bad42'})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
self.assertEquals(app.memcache._allow_pickle, True)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '6.7.8.9:10')
self.assertEqual(app.memcache._allow_pickle, True)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['6.7.8.9:10'].max_size, 4)
def test_conf_from_extra_conf(self):
@ -248,10 +248,10 @@ class TestCacheMiddleware(unittest.TestCase):
app = memcache.MemcacheMiddleware(FakeApp(), {})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '1.2.3.4:5')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '1.2.3.4:5')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['1.2.3.4:5'].max_size, 4)
def test_conf_from_extra_conf_bad_max_conn(self):
@ -262,10 +262,10 @@ class TestCacheMiddleware(unittest.TestCase):
app = memcache.MemcacheMiddleware(FakeApp(), {})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '1.2.3.4:5')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '1.2.3.4:5')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['1.2.3.4:5'].max_size, 2)
def test_conf_from_inline_and_maxc_from_extra_conf(self):
@ -278,10 +278,10 @@ class TestCacheMiddleware(unittest.TestCase):
'memcache_serialization_support': '0'})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
self.assertEquals(app.memcache._allow_pickle, True)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '6.7.8.9:10')
self.assertEqual(app.memcache._allow_pickle, True)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['6.7.8.9:10'].max_size, 4)
def test_conf_from_inline_and_sers_from_extra_conf(self):
@ -294,10 +294,10 @@ class TestCacheMiddleware(unittest.TestCase):
'memcache_max_connections': '42'})
finally:
memcache.ConfigParser = orig_parser
self.assertEquals(app.memcache_servers, '6.7.8.9:10')
self.assertEquals(app.memcache._allow_pickle, False)
self.assertEquals(app.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(app.memcache_servers, '6.7.8.9:10')
self.assertEqual(app.memcache._allow_pickle, False)
self.assertEqual(app.memcache._allow_unpickle, True)
self.assertEqual(
app.memcache._client_cache['6.7.8.9:10'].max_size, 42)
def test_filter_factory(self):
@ -305,11 +305,11 @@ class TestCacheMiddleware(unittest.TestCase):
memcache_servers='10.10.10.10:10',
memcache_serialization_support='1')
thefilter = factory('myapp')
self.assertEquals(thefilter.app, 'myapp')
self.assertEquals(thefilter.memcache_servers, '10.10.10.10:10')
self.assertEquals(thefilter.memcache._allow_pickle, False)
self.assertEquals(thefilter.memcache._allow_unpickle, True)
self.assertEquals(
self.assertEqual(thefilter.app, 'myapp')
self.assertEqual(thefilter.memcache_servers, '10.10.10.10:10')
self.assertEqual(thefilter.memcache._allow_pickle, False)
self.assertEqual(thefilter.memcache._allow_unpickle, True)
self.assertEqual(
thefilter.memcache._client_cache['10.10.10.10:10'].max_size, 3)
@patch_policies

View File

@ -48,7 +48,7 @@ class TestNameCheckMiddleware(unittest.TestCase):
path = '/V1.0/' + 'c' * (MAX_LENGTH - 6)
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.body, 'OK')
self.assertEqual(resp.body, 'OK')
def test_invalid_character(self):
for c in self.conf['forbidden_chars']:
@ -56,11 +56,11 @@ class TestNameCheckMiddleware(unittest.TestCase):
resp = Request.blank(
path, environ={'REQUEST_METHOD': 'PUT'}).get_response(
self.test_check)
self.assertEquals(
self.assertEqual(
resp.body,
("Object/Container/Account name contains forbidden chars "
"from %s" % self.conf['forbidden_chars']))
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
def test_maximum_length_from_config(self):
# test invalid length
@ -70,29 +70,29 @@ class TestNameCheckMiddleware(unittest.TestCase):
path = '/V1.0/a/c' + 'o' * (500 - 8)
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(
self.assertEqual(
resp.body,
("Object/Container/Account name longer than the allowed "
"maximum 500"))
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
# test valid length
path = '/V1.0/a/c' + 'o' * (MAX_LENGTH - 10)
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.body, 'OK')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.body, 'OK')
self.test_check = orig_test_check
def test_invalid_length(self):
path = '/V1.0/' + 'c' * (MAX_LENGTH - 5)
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
).get_response(self.test_check)
self.assertEquals(
self.assertEqual(
resp.body,
("Object/Container/Account name longer than the allowed maximum %s"
% self.conf['maximum_length']))
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
def test_invalid_regexp(self):
for s in ['/.', '/..', '/./foo', '/../foo']:
@ -100,12 +100,12 @@ class TestNameCheckMiddleware(unittest.TestCase):
resp = Request.blank(
path, environ={'REQUEST_METHOD': 'PUT'}).get_response(
self.test_check)
self.assertEquals(
self.assertEqual(
resp.body,
("Object/Container/Account name contains a forbidden "
"substring from regular expression %s"
% self.conf['forbidden_regexp']))
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
def test_valid_regexp(self):
for s in ['/...', '/.\.', '/foo']:
@ -113,7 +113,7 @@ class TestNameCheckMiddleware(unittest.TestCase):
resp = Request.blank(
path, environ={'REQUEST_METHOD': 'PUT'}).get_response(
self.test_check)
self.assertEquals(resp.body, 'OK')
self.assertEqual(resp.body, 'OK')
if __name__ == '__main__':

View File

@ -114,17 +114,17 @@ class TestProxyLogging(unittest.TestCase):
def _log_parts(self, app, should_be_empty=False):
info_calls = app.access_logger.log_dict['info']
if should_be_empty:
self.assertEquals([], info_calls)
self.assertEqual([], info_calls)
else:
self.assertEquals(1, len(info_calls))
self.assertEqual(1, len(info_calls))
return info_calls[0][0][0].split(' ')
def assertTiming(self, exp_metric, app, exp_timing=None):
timing_calls = app.access_logger.log_dict['timing']
found = False
for timing_call in timing_calls:
self.assertEquals({}, timing_call[1])
self.assertEquals(2, len(timing_call[0]))
self.assertEqual({}, timing_call[1])
self.assertEqual(2, len(timing_call[0]))
if timing_call[0][0] == exp_metric:
found = True
if exp_timing is not None:
@ -138,8 +138,8 @@ class TestProxyLogging(unittest.TestCase):
timing_calls = app.access_logger.log_dict['timing_since']
found = False
for timing_call in timing_calls:
self.assertEquals({}, timing_call[1])
self.assertEquals(2, len(timing_call[0]))
self.assertEqual({}, timing_call[1])
self.assertEqual(2, len(timing_call[0]))
if timing_call[0][0] == exp_metric:
found = True
if exp_start is not None:
@ -395,12 +395,12 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'FAKE APP')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'FAKE APP')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_basic_req_second_time(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
@ -411,7 +411,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
self._log_parts(app, should_be_empty=True)
self.assertEquals(resp_body, 'FAKE APP')
self.assertEqual(resp_body, 'FAKE APP')
def test_multi_segment_resp(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(
@ -422,12 +422,12 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'somechunksof data')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'somechunksof data')
self.assertEqual(log_parts[11], str(len(resp_body)))
self.assertUpdateStats([('SOS.GET.200.xfer', len(resp_body))], app)
def test_log_headers(self):
@ -476,8 +476,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[11], str(len('FAKE APP')))
self.assertEquals(log_parts[10], str(len('some stuff')))
self.assertEqual(log_parts[11], str(len('FAKE APP')))
self.assertEqual(log_parts[10], str(len('some stuff')))
self.assertUpdateStats([('object.PUT.200.xfer',
len('some stuff') + len('FAKE APP')),
('object.policy.0.PUT.200.xfer',
@ -496,8 +496,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[11], str(len('FAKE APP')))
self.assertEquals(log_parts[10], str(len('some stuff')))
self.assertEqual(log_parts[11], str(len('FAKE APP')))
self.assertEqual(log_parts[10], str(len('some stuff')))
self.assertUpdateStats([('object.PUT.200.xfer',
len('some stuff') + len('FAKE APP'))],
app)
@ -514,8 +514,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[11], str(len('FAKE APP')))
self.assertEquals(log_parts[10], str(len('some stuff')))
self.assertEqual(log_parts[11], str(len('FAKE APP')))
self.assertEqual(log_parts[10], str(len('some stuff')))
self.assertUpdateStats([('object.PUT.200.xfer',
len('some stuff') + len('FAKE APP'))],
app)
@ -532,8 +532,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[11], str(len('FAKE APP')))
self.assertEquals(log_parts[10], str(len('some stuff\n')))
self.assertEqual(log_parts[11], str(len('FAKE APP')))
self.assertEqual(log_parts[10], str(len('some stuff\n')))
self.assertUpdateStats([('container.POST.200.xfer',
len('some stuff\n') + len('FAKE APP'))],
app)
@ -547,7 +547,7 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(unquote(log_parts[4]), '/?x=3')
self.assertEqual(unquote(log_parts[4]), '/?x=3')
def test_client_logging(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
@ -558,8 +558,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[0], '1.2.3.4') # client ip
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
self.assertEqual(log_parts[0], '1.2.3.4') # client ip
self.assertEqual(log_parts[1], '1.2.3.4') # remote addr
def test_iterator_closing(self):
@ -593,8 +593,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
self.assertEqual(log_parts[0], '4.5.6.7') # client ip
self.assertEqual(log_parts[1], '1.2.3.4') # remote addr
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
app.access_logger = FakeLogger()
@ -606,8 +606,8 @@ class TestProxyLogging(unittest.TestCase):
# exhaust generator
[x for x in resp]
log_parts = self._log_parts(app)
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
self.assertEqual(log_parts[0], '4.5.6.7') # client ip
self.assertEqual(log_parts[1], '1.2.3.4') # remote addr
def test_facility(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -615,7 +615,7 @@ class TestProxyLogging(unittest.TestCase):
{'log_headers': 'yes',
'access_log_facility': 'LOG_LOCAL7'})
handler = get_logger.handler4logger[app.access_logger.logger]
self.assertEquals(SysLogHandler.LOG_LOCAL7, handler.facility)
self.assertEqual(SysLogHandler.LOG_LOCAL7, handler.facility)
def test_filter(self):
factory = proxy_logging.filter_factory({})
@ -632,8 +632,8 @@ class TestProxyLogging(unittest.TestCase):
next(resp)
resp.close() # raise a GeneratorExit in middleware app_iter loop
log_parts = self._log_parts(app)
self.assertEquals(log_parts[6], '499')
self.assertEquals(log_parts[11], '4') # write length
self.assertEqual(log_parts[6], '499')
self.assertEqual(log_parts[11], '4') # write length
def test_disconnect_on_readline(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeAppReadline(), {})
@ -647,8 +647,8 @@ class TestProxyLogging(unittest.TestCase):
except IOError:
pass
log_parts = self._log_parts(app)
self.assertEquals(log_parts[6], '499')
self.assertEquals(log_parts[10], '-') # read length
self.assertEqual(log_parts[6], '499')
self.assertEqual(log_parts[10], '-') # read length
def test_disconnect_on_read(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -663,8 +663,8 @@ class TestProxyLogging(unittest.TestCase):
except IOError:
pass
log_parts = self._log_parts(app)
self.assertEquals(log_parts[6], '499')
self.assertEquals(log_parts[10], '-') # read length
self.assertEqual(log_parts[6], '499')
self.assertEqual(log_parts[10], '-') # read length
def test_app_exception(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -676,8 +676,8 @@ class TestProxyLogging(unittest.TestCase):
except Exception:
pass
log_parts = self._log_parts(app)
self.assertEquals(log_parts[6], '500')
self.assertEquals(log_parts[10], '-') # read length
self.assertEqual(log_parts[6], '500')
self.assertEqual(log_parts[10], '-') # read length
def test_no_content_length_no_transfer_encoding_with_list_body(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -690,12 +690,12 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'line1\nline2\n')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'line1\nline2\n')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_no_content_length_no_transfer_encoding_with_empty_strings(self):
app = proxy_logging.ProxyLoggingMiddleware(
@ -708,12 +708,12 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, '')
self.assertEquals(log_parts[11], '-')
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, '')
self.assertEqual(log_parts[11], '-')
def test_no_content_length_no_transfer_encoding_with_generator(self):
@ -733,28 +733,28 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'abc')
self.assertEquals(log_parts[11], '3')
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'abc')
self.assertEqual(log_parts[11], '3')
def test_req_path_info_popping(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
app.access_logger = FakeLogger()
req = Request.blank('/v1/something', environ={'REQUEST_METHOD': 'GET'})
req.path_info_pop()
self.assertEquals(req.environ['PATH_INFO'], '/something')
self.assertEqual(req.environ['PATH_INFO'], '/something')
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/v1/something')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'FAKE APP')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/v1/something')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'FAKE APP')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_ipv6(self):
ipv6addr = '2001:db8:85a3:8d3:1319:8a2e:370:7348'
@ -765,14 +765,14 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[0], ipv6addr)
self.assertEquals(log_parts[1], ipv6addr)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'FAKE APP')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[0], ipv6addr)
self.assertEqual(log_parts[1], ipv6addr)
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'FAKE APP')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_log_info_none(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
@ -780,7 +780,7 @@ class TestProxyLogging(unittest.TestCase):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
list(app(req.environ, start_response))
log_parts = self._log_parts(app)
self.assertEquals(log_parts[17], '-')
self.assertEqual(log_parts[17], '-')
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
app.access_logger = FakeLogger()
@ -788,7 +788,7 @@ class TestProxyLogging(unittest.TestCase):
req.environ['swift.log_info'] = []
list(app(req.environ, start_response))
log_parts = self._log_parts(app)
self.assertEquals(log_parts[17], '-')
self.assertEqual(log_parts[17], '-')
def test_log_info_single(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
@ -797,7 +797,7 @@ class TestProxyLogging(unittest.TestCase):
req.environ['swift.log_info'] = ['one']
list(app(req.environ, start_response))
log_parts = self._log_parts(app)
self.assertEquals(log_parts[17], 'one')
self.assertEqual(log_parts[17], 'one')
def test_log_info_multiple(self):
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
@ -806,7 +806,7 @@ class TestProxyLogging(unittest.TestCase):
req.environ['swift.log_info'] = ['one', 'and two']
list(app(req.environ, start_response))
log_parts = self._log_parts(app)
self.assertEquals(log_parts[17], 'one%2Cand%20two')
self.assertEqual(log_parts[17], 'one%2Cand%20two')
def test_log_auth_token(self):
auth_token = 'b05bf940-0464-4c0e-8c70-87717d2d73e8'
@ -819,7 +819,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], '-')
self.assertEqual(log_parts[9], '-')
# Has x-auth-token header
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {})
app.access_logger = FakeLogger()
@ -828,7 +828,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], 'b05bf940-0464-4c...')
self.assertEqual(log_parts[9], 'b05bf940-0464-4c...')
# Truncate to first 8 characters
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
@ -838,7 +838,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], '-')
self.assertEqual(log_parts[9], '-')
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
'reveal_sensitive_prefix': '8'})
app.access_logger = FakeLogger()
@ -847,7 +847,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], 'b05bf940...')
self.assertEqual(log_parts[9], 'b05bf940...')
# Token length and reveal_sensitive_prefix are same (no truncate)
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
@ -858,7 +858,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], auth_token)
self.assertEqual(log_parts[9], auth_token)
# No effective limit on auth token
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
@ -869,7 +869,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], auth_token)
self.assertEqual(log_parts[9], auth_token)
# Don't log x-auth-token
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
@ -879,7 +879,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], '-')
self.assertEqual(log_parts[9], '-')
app = proxy_logging.ProxyLoggingMiddleware(FakeApp(), {
'reveal_sensitive_prefix': '0'})
app.access_logger = FakeLogger()
@ -888,7 +888,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[9], '...')
self.assertEqual(log_parts[9], '...')
# Avoids pyflakes error, "local variable 'resp_body' is assigned to
# but never used
@ -904,29 +904,29 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
resp_body = ''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(len(log_parts), 21)
self.assertEquals(log_parts[0], '-')
self.assertEquals(log_parts[1], '-')
self.assertEquals(log_parts[2], '26/Apr/1970/17/46/41')
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(log_parts[7], '-')
self.assertEquals(log_parts[8], '-')
self.assertEquals(log_parts[9], '-')
self.assertEquals(log_parts[10], '-')
self.assertEquals(resp_body, 'FAKE APP')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEquals(log_parts[12], '-')
self.assertEquals(log_parts[13], '-')
self.assertEquals(log_parts[14], '-')
self.assertEquals(log_parts[15], '1.0000')
self.assertEquals(log_parts[16], '-')
self.assertEquals(log_parts[17], '-')
self.assertEquals(log_parts[18], '10000000.000000000')
self.assertEquals(log_parts[19], '10000001.000000000')
self.assertEquals(log_parts[20], '-')
self.assertEqual(len(log_parts), 21)
self.assertEqual(log_parts[0], '-')
self.assertEqual(log_parts[1], '-')
self.assertEqual(log_parts[2], '26/Apr/1970/17/46/41')
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(log_parts[7], '-')
self.assertEqual(log_parts[8], '-')
self.assertEqual(log_parts[9], '-')
self.assertEqual(log_parts[10], '-')
self.assertEqual(resp_body, 'FAKE APP')
self.assertEqual(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[12], '-')
self.assertEqual(log_parts[13], '-')
self.assertEqual(log_parts[14], '-')
self.assertEqual(log_parts[15], '1.0000')
self.assertEqual(log_parts[16], '-')
self.assertEqual(log_parts[17], '-')
self.assertEqual(log_parts[18], '10000000.000000000')
self.assertEqual(log_parts[19], '10000001.000000000')
self.assertEqual(log_parts[20], '-')
def test_dual_logging_middlewares(self):
# Since no internal request is being made, outer most proxy logging
@ -943,12 +943,12 @@ class TestProxyLogging(unittest.TestCase):
resp_body = ''.join(resp)
self._log_parts(log0, should_be_empty=True)
log_parts = self._log_parts(log1)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'FAKE APP')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'FAKE APP')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_dual_logging_middlewares_w_inner(self):
@ -994,20 +994,20 @@ class TestProxyLogging(unittest.TestCase):
# Inner most logger should have logged the app's response
log_parts = self._log_parts(log0)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(log_parts[11], str(len('FAKE APP')))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(log_parts[11], str(len('FAKE APP')))
# Outer most logger should have logged the other middleware's response
log_parts = self._log_parts(log1)
self.assertEquals(log_parts[3], 'GET')
self.assertEquals(log_parts[4], '/')
self.assertEquals(log_parts[5], 'HTTP/1.0')
self.assertEquals(log_parts[6], '200')
self.assertEquals(resp_body, 'FAKE MIDDLEWARE')
self.assertEquals(log_parts[11], str(len(resp_body)))
self.assertEqual(log_parts[3], 'GET')
self.assertEqual(log_parts[4], '/')
self.assertEqual(log_parts[5], 'HTTP/1.0')
self.assertEqual(log_parts[6], '200')
self.assertEqual(resp_body, 'FAKE MIDDLEWARE')
self.assertEqual(log_parts[11], str(len(resp_body)))
def test_policy_index(self):
# Policy index can be specified by X-Backend-Storage-Policy-Index
@ -1018,7 +1018,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[20], '1')
self.assertEqual(log_parts[20], '1')
# Policy index can be specified by X-Backend-Storage-Policy-Index
# in the response header for container API
@ -1039,7 +1039,7 @@ class TestProxyLogging(unittest.TestCase):
resp = app(req.environ, start_response)
''.join(resp)
log_parts = self._log_parts(app)
self.assertEquals(log_parts[20], '1')
self.assertEqual(log_parts[20], '1')
if __name__ == '__main__':

View File

@ -62,18 +62,18 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT',
'swift.cache': {'key': 'value'}})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_handled(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
req = Request.blank('/v1/a/c', environ={'REQUEST_METHOD': 'PUT'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
req = Request.blank('/v1/a/c/o', environ={'REQUEST_METHOD': 'GET'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_no_quotas(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -82,7 +82,7 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': FakeCache({}),
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_bytes_quota(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -92,8 +92,8 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_bytes_quota_copy_from(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -105,8 +105,8 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_bytes_quota_copy_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -118,8 +118,8 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_not_exceed_bytes_quota(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -129,7 +129,7 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_bytes_quota_copy_from(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -140,7 +140,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_bytes_quota_copy_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -151,7 +151,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_bytes_quota_copy_from_no_src(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -162,7 +162,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o3'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_bytes_quota_copy_from_bad_src(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -172,7 +172,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': 'bad_path'})
res = req.get_response(app)
self.assertEquals(res.status_int, 412)
self.assertEqual(res.status_int, 412)
def test_bytes_quota_copy_verb_no_src(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -183,7 +183,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_exceed_counts_quota(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -193,8 +193,8 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_counts_quota_copy_from(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -205,8 +205,8 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_counts_quota_copy_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -216,8 +216,8 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_counts_quota_copy_cross_account_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -232,8 +232,8 @@ class TestContainerQuotas(unittest.TestCase):
headers={'Destination': '/c/o',
'Destination-Account': 'a2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_exceed_counts_quota_copy_cross_account_PUT_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -248,8 +248,8 @@ class TestContainerQuotas(unittest.TestCase):
headers={'X-Copy-From': '/c2/o2',
'X-Copy-From-Account': 'a'})
res = req.get_response(app)
self.assertEquals(res.status_int, 413)
self.assertEquals(res.body, 'Upload exceeds quota.')
self.assertEqual(res.status_int, 413)
self.assertEqual(res.body, 'Upload exceeds quota.')
def test_not_exceed_counts_quota(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -259,7 +259,7 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_counts_quota_copy_from(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -269,7 +269,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'x-copy-from': '/c2/o2'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_not_exceed_counts_quota_copy_verb(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -279,7 +279,7 @@ class TestContainerQuotas(unittest.TestCase):
'swift.cache': cache},
headers={'Destination': '/c/o'})
res = req.get_response(app)
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_invalid_quotas(self):
req = Request.blank(
@ -288,7 +288,7 @@ class TestContainerQuotas(unittest.TestCase):
'HTTP_X_CONTAINER_META_QUOTA_BYTES': 'abc'})
res = req.get_response(
container_quotas.ContainerQuotaMiddleware(FakeApp(), {}))
self.assertEquals(res.status_int, 400)
self.assertEqual(res.status_int, 400)
req = Request.blank(
'/v1/a/c',
@ -296,7 +296,7 @@ class TestContainerQuotas(unittest.TestCase):
'HTTP_X_CONTAINER_META_QUOTA_COUNT': 'abc'})
res = req.get_response(
container_quotas.ContainerQuotaMiddleware(FakeApp(), {}))
self.assertEquals(res.status_int, 400)
self.assertEqual(res.status_int, 400)
def test_valid_quotas(self):
req = Request.blank(
@ -305,7 +305,7 @@ class TestContainerQuotas(unittest.TestCase):
'HTTP_X_CONTAINER_META_QUOTA_BYTES': '123'})
res = req.get_response(
container_quotas.ContainerQuotaMiddleware(FakeApp(), {}))
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
req = Request.blank(
'/v1/a/c',
@ -313,7 +313,7 @@ class TestContainerQuotas(unittest.TestCase):
'HTTP_X_CONTAINER_META_QUOTA_COUNT': '123'})
res = req.get_response(
container_quotas.ContainerQuotaMiddleware(FakeApp(), {}))
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_delete_quotas(self):
req = Request.blank(
@ -322,7 +322,7 @@ class TestContainerQuotas(unittest.TestCase):
'HTTP_X_CONTAINER_META_QUOTA_BYTES': None})
res = req.get_response(
container_quotas.ContainerQuotaMiddleware(FakeApp(), {}))
self.assertEquals(res.status_int, 200)
self.assertEqual(res.status_int, 200)
def test_missing_container(self):
app = container_quotas.ContainerQuotaMiddleware(FakeMissingApp(), {})
@ -332,7 +332,7 @@ class TestContainerQuotas(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
res = req.get_response(app)
self.assertEquals(res.status_int, 404)
self.assertEqual(res.status_int, 404)
def test_auth_fail(self):
app = container_quotas.ContainerQuotaMiddleware(FakeApp(), {})
@ -344,7 +344,7 @@ class TestContainerQuotas(unittest.TestCase):
'CONTENT_LENGTH': '100',
'swift.authorize': lambda *args: HTTPUnauthorized()})
res = req.get_response(app)
self.assertEquals(res.status_int, 401)
self.assertEqual(res.status_int, 401)
if __name__ == '__main__':
unittest.main()

View File

@ -159,7 +159,7 @@ class TestRateLimit(unittest.TestCase):
# Allow for one second of variation in the total time.
time_diff = abs(total_time - (end - begin))
if check_time:
self.assertEquals(round(total_time, 1), round(time_ticker, 1))
self.assertEqual(round(total_time, 1), round(time_ticker, 1))
return time_diff
def test_get_maxrate(self):
@ -168,15 +168,15 @@ class TestRateLimit(unittest.TestCase):
'container_ratelimit_75': 30}
test_ratelimit = ratelimit.filter_factory(conf_dict)(FakeApp())
test_ratelimit.logger = FakeLogger()
self.assertEquals(ratelimit.get_maxrate(
self.assertEqual(ratelimit.get_maxrate(
test_ratelimit.container_ratelimits, 0), None)
self.assertEquals(ratelimit.get_maxrate(
self.assertEqual(ratelimit.get_maxrate(
test_ratelimit.container_ratelimits, 5), None)
self.assertEquals(ratelimit.get_maxrate(
self.assertEqual(ratelimit.get_maxrate(
test_ratelimit.container_ratelimits, 10), 200)
self.assertEquals(ratelimit.get_maxrate(
self.assertEqual(ratelimit.get_maxrate(
test_ratelimit.container_ratelimits, 60), 72)
self.assertEquals(ratelimit.get_maxrate(
self.assertEqual(ratelimit.get_maxrate(
test_ratelimit.container_ratelimits, 160), 30)
def test_get_ratelimitable_key_tuples(self):
@ -193,35 +193,35 @@ class TestRateLimit(unittest.TestCase):
with mock.patch('swift.common.middleware.ratelimit.get_account_info',
lambda *args, **kwargs: {}):
req.method = 'DELETE'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', None, None)), 0)
req.method = 'PUT'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', None)), 1)
req.method = 'DELETE'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', None)), 1)
req.method = 'GET'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', 'o')), 0)
req.method = 'PUT'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', 'o')), 1)
req.method = 'PUT'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', None, global_ratelimit=10)), 2)
self.assertEquals(the_app.get_ratelimitable_key_tuples(
self.assertEqual(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', None, global_ratelimit=10)[1],
('ratelimit/global-write/a', 10))
req.method = 'PUT'
self.assertEquals(len(the_app.get_ratelimitable_key_tuples(
self.assertEqual(len(the_app.get_ratelimitable_key_tuples(
req, 'a', 'c', None, global_ratelimit='notafloat')), 1)
def test_memcached_container_info_dict(self):
mdict = headers_to_container_info({'x-container-object-count': '45'})
self.assertEquals(mdict['object_count'], '45')
self.assertEqual(mdict['object_count'], '45')
def test_ratelimit_old_memcache_format(self):
current_rate = 13
@ -238,7 +238,7 @@ class TestRateLimit(unittest.TestCase):
with mock.patch('swift.common.middleware.ratelimit.get_account_info',
lambda *args, **kwargs: {}):
tuples = the_app.get_ratelimitable_key_tuples(req, 'a', 'c', 'o')
self.assertEquals(tuples, [('ratelimit/a/c', 200.0)])
self.assertEqual(tuples, [('ratelimit/a/c', 200.0)])
def test_account_ratelimit(self):
current_rate = 5
@ -261,7 +261,7 @@ class TestRateLimit(unittest.TestCase):
begin = time.time()
self._run(make_app_call, num_calls, current_rate,
check_time=bool(exp_time))
self.assertEquals(round(time.time() - begin, 1), exp_time)
self.assertEqual(round(time.time() - begin, 1), exp_time)
self._reset_time()
def test_ratelimit_set_incr(self):
@ -280,7 +280,7 @@ class TestRateLimit(unittest.TestCase):
with mock.patch('swift.common.middleware.ratelimit.get_account_info',
lambda *args, **kwargs: {}):
self._run(make_app_call, num_calls, current_rate, check_time=False)
self.assertEquals(round(time.time() - begin, 1), 9.8)
self.assertEqual(round(time.time() - begin, 1), 9.8)
def test_ratelimit_old_white_black_list(self):
global time_ticker
@ -339,8 +339,8 @@ class TestRateLimit(unittest.TestCase):
the_498s = [
t for t in threads
if ''.join(t.result).startswith('Slow down')]
self.assertEquals(len(the_498s), 0)
self.assertEquals(time_ticker, 0)
self.assertEqual(len(the_498s), 0)
self.assertEqual(time_ticker, 0)
def test_ratelimit_blacklist(self):
global time_ticker
@ -382,8 +382,8 @@ class TestRateLimit(unittest.TestCase):
the_497s = [
t for t in threads
if ''.join(t.result).startswith('Your account')]
self.assertEquals(len(the_497s), 5)
self.assertEquals(time_ticker, 0)
self.assertEqual(len(the_497s), 5)
self.assertEqual(time_ticker, 0)
def test_ratelimit_max_rate_double(self):
global time_ticker
@ -408,13 +408,13 @@ class TestRateLimit(unittest.TestCase):
r = self.test_ratelimit(req.environ, start_response)
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], '204 No Content')
self.assertEqual(r[0], '204 No Content')
def test_ratelimit_max_rate_double_container(self):
global time_ticker
@ -442,13 +442,13 @@ class TestRateLimit(unittest.TestCase):
r = self.test_ratelimit(req.environ, start_response)
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], '204 No Content')
self.assertEqual(r[0], '204 No Content')
def test_ratelimit_max_rate_double_container_listing(self):
global time_ticker
@ -476,17 +476,17 @@ class TestRateLimit(unittest.TestCase):
r = self.test_ratelimit(req.environ, start_response)
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], 'Slow down')
self.assertEqual(r[0], 'Slow down')
mock_sleep(.1)
r = self.test_ratelimit(req.environ, start_response)
self.assertEquals(r[0], '204 No Content')
self.assertEqual(r[0], '204 No Content')
mc = self.test_ratelimit.memcache_client
try:
self.test_ratelimit.memcache_client = None
self.assertEquals(
self.assertEqual(
self.test_ratelimit.handle_ratelimit(req, 'n', 'c', None),
None)
finally:
@ -529,7 +529,7 @@ class TestRateLimit(unittest.TestCase):
thread.join()
time_took = time.time() - begin
self.assertEquals(1.5, round(time_took, 1))
self.assertEqual(1.5, round(time_took, 1))
def test_call_invalid_path(self):
env = {'REQUEST_METHOD': 'GET',
@ -563,7 +563,7 @@ class TestRateLimit(unittest.TestCase):
begin = time.time()
self._run(make_app_call, num_calls, current_rate, check_time=False)
time_took = time.time() - begin
self.assertEquals(round(time_took, 1), 0) # no memcache, no limiting
self.assertEqual(round(time_took, 1), 0) # no memcache, no limiting
def test_restarting_memcache(self):
current_rate = 2
@ -582,7 +582,7 @@ class TestRateLimit(unittest.TestCase):
lambda *args, **kwargs: {}):
self._run(make_app_call, num_calls, current_rate, check_time=False)
time_took = time.time() - begin
self.assertEquals(round(time_took, 1), 0) # no memcache, no limit
self.assertEqual(round(time_took, 1), 0) # no memcache, no limit
class TestSwiftInfo(unittest.TestCase):

View File

@ -310,7 +310,7 @@ class TestReconSuccess(TestCase):
# object-{1,2}.ring.gz should both appear as they are present on disk
# and were configured as policies.
app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir})
self.assertEquals(sorted(app.get_ring_md5().items()),
self.assertEqual(sorted(app.get_ring_md5().items()),
sorted(expt_out.items()))
def test_get_ring_md5_ioerror_produces_none_hash(self):
@ -326,7 +326,7 @@ class TestReconSuccess(TestCase):
'%s/container.ring.gz' % self.tempdir: None,
'%s/object.ring.gz' % self.tempdir: None}
ringmd5 = self.app.get_ring_md5(openr=fake_open)
self.assertEquals(sorted(ringmd5.items()),
self.assertEqual(sorted(ringmd5.items()),
sorted(expt_out.items()))
def test_get_ring_md5_failed_ring_hash_recovers_without_restart(self):
@ -341,7 +341,7 @@ class TestReconSuccess(TestCase):
'%s/container.ring.gz' % self.tempdir: None,
'%s/object.ring.gz' % self.tempdir: None}
ringmd5 = self.app.get_ring_md5(openr=fake_open)
self.assertEquals(sorted(ringmd5.items()),
self.assertEqual(sorted(ringmd5.items()),
sorted(expt_out.items()))
# If we fix a ring and it can be read again, its hash should then
@ -356,7 +356,7 @@ class TestReconSuccess(TestCase):
'%s/object.ring.gz' % self.tempdir:
'da02bfbd0bf1e7d56faea15b6fe5ab1e'}
ringmd5 = self.app.get_ring_md5(openr=fake_open_objonly)
self.assertEquals(sorted(ringmd5.items()),
self.assertEqual(sorted(ringmd5.items()),
sorted(expt_out.items()))
@patch_policies([
@ -382,7 +382,7 @@ class TestReconSuccess(TestCase):
# object-3502.ring.gz should not appear as it's configured but not
# present.
app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir})
self.assertEquals(sorted(app.get_ring_md5().items()),
self.assertEqual(sorted(app.get_ring_md5().items()),
sorted(expt_out.items()))
# Simulate the configured policy's missing ringfile being moved into
@ -398,7 +398,7 @@ class TestReconSuccess(TestCase):
# We should now see it in the ringmd5 response, without a restart
# (using the same app instance)
self.assertEquals(sorted(app.get_ring_md5().items()),
self.assertEqual(sorted(app.get_ring_md5().items()),
sorted(expt_out.items()))
@patch_policies([
@ -423,7 +423,7 @@ class TestReconSuccess(TestCase):
# object-2305.ring.gz should not appear as it's configured but not
# present.
app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir})
self.assertEquals(sorted(app.get_ring_md5().items()),
self.assertEqual(sorted(app.get_ring_md5().items()),
sorted(expt_out.items()))
@patch_policies([
@ -443,7 +443,7 @@ class TestReconSuccess(TestCase):
# object-{1,2}.ring.gz should not appear as they are present on disk
# but were not configured as policies.
app = recon.ReconMiddleware(FakeApp(), {'swift_dir': self.tempdir})
self.assertEquals(sorted(app.get_ring_md5().items()),
self.assertEqual(sorted(app.get_ring_md5().items()),
sorted(expt_out.items()))
def test_from_recon_cache(self):
@ -451,9 +451,9 @@ class TestReconSuccess(TestCase):
self.app._from_recon_cache = self.real_from_cache
rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'],
'test.cache', openr=oart.open)
self.assertEquals(oart.read_calls, [((), {})])
self.assertEquals(oart.open_calls, [(('test.cache', 'r'), {})])
self.assertEquals(rv, {'notpresentkey': None, 'testkey1': 'canhazio'})
self.assertEqual(oart.read_calls, [((), {})])
self.assertEqual(oart.open_calls, [(('test.cache', 'r'), {})])
self.assertEqual(rv, {'notpresentkey': None, 'testkey1': 'canhazio'})
self.app._from_recon_cache = self.fakecache.fake_from_recon_cache
def test_from_recon_cache_ioerror(self):
@ -461,7 +461,7 @@ class TestReconSuccess(TestCase):
self.app._from_recon_cache = self.real_from_cache
rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'],
'test.cache', openr=oart)
self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None})
self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None})
self.app._from_recon_cache = self.fakecache.fake_from_recon_cache
def test_from_recon_cache_valueerror(self):
@ -469,7 +469,7 @@ class TestReconSuccess(TestCase):
self.app._from_recon_cache = self.real_from_cache
rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'],
'test.cache', openr=oart)
self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None})
self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None})
self.app._from_recon_cache = self.fakecache.fake_from_recon_cache
def test_from_recon_cache_exception(self):
@ -477,7 +477,7 @@ class TestReconSuccess(TestCase):
self.app._from_recon_cache = self.real_from_cache
rv = self.app._from_recon_cache(['testkey1', 'notpresentkey'],
'test.cache', openr=oart)
self.assertEquals(rv, {'notpresentkey': None, 'testkey1': None})
self.assertEqual(rv, {'notpresentkey': None, 'testkey1': None})
self.app._from_recon_cache = self.fakecache.fake_from_recon_cache
def test_get_mounted(self):
@ -525,15 +525,15 @@ class TestReconSuccess(TestCase):
{'device': 'none', 'path': '/proc/fs/vmblock/mountPoint'}]
oart = OpenAndReadTester(mounts_content)
rv = self.app.get_mounted(openr=oart.open)
self.assertEquals(oart.open_calls, [(('/proc/mounts', 'r'), {})])
self.assertEquals(rv, mounted_resp)
self.assertEqual(oart.open_calls, [(('/proc/mounts', 'r'), {})])
self.assertEqual(rv, mounted_resp)
def test_get_load(self):
oart = OpenAndReadTester(['0.03 0.03 0.00 1/220 16306'])
rv = self.app.get_load(openr=oart.open)
self.assertEquals(oart.read_calls, [((), {})])
self.assertEquals(oart.open_calls, [(('/proc/loadavg', 'r'), {})])
self.assertEquals(rv, {'5m': 0.029999999999999999, '15m': 0.0,
self.assertEqual(oart.read_calls, [((), {})])
self.assertEqual(oart.open_calls, [(('/proc/loadavg', 'r'), {})])
self.assertEqual(rv, {'5m': 0.029999999999999999, '15m': 0.0,
'processes': 16306, 'tasks': '1/220',
'1m': 0.029999999999999999})
@ -623,17 +623,17 @@ class TestReconSuccess(TestCase):
'Dirty': '104 kB'}
oart = OpenAndReadTester(meminfo_content)
rv = self.app.get_mem(openr=oart.open)
self.assertEquals(oart.open_calls, [(('/proc/meminfo', 'r'), {})])
self.assertEquals(rv, meminfo_resp)
self.assertEqual(oart.open_calls, [(('/proc/meminfo', 'r'), {})])
self.assertEqual(rv, meminfo_resp)
def test_get_async_info(self):
from_cache_response = {'async_pending': 5}
self.fakecache.fakeout = from_cache_response
rv = self.app.get_async_info()
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['async_pending'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, {'async_pending': 5})
self.assertEqual(rv, {'async_pending': 5})
def test_get_replication_info_account(self):
from_cache_response = {
@ -652,11 +652,11 @@ class TestReconSuccess(TestCase):
"replication_last": 1357969645.25}
self.fakecache.fakeout = from_cache_response
rv = self.app.get_replication_info('account')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['replication_time', 'replication_stats',
'replication_last'],
'/var/cache/swift/account.recon'), {})])
self.assertEquals(rv, {
self.assertEqual(rv, {
"replication_stats": {
"attempted": 1, "diff": 0,
"diff_capped": 0, "empty": 0,
@ -689,11 +689,11 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_replication_info('container')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['replication_time', 'replication_stats',
'replication_last'],
'/var/cache/swift/container.recon'), {})])
self.assertEquals(rv, {
self.assertEqual(rv, {
"replication_time": 200.0,
"replication_stats": {
"attempted": 179, "diff": 0,
@ -725,12 +725,12 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_replication_info('object')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['replication_time', 'replication_stats',
'replication_last', 'object_replication_time',
'object_replication_last'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, {
self.assertEqual(rv, {
"replication_time": 0.2615511417388916,
"replication_stats": {
"attempted": 179,
@ -749,20 +749,20 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_updater_info('container')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['container_updater_sweep'],
'/var/cache/swift/container.recon'), {})])
self.assertEquals(rv, {"container_updater_sweep": 18.476239919662476})
self.assertEqual(rv, {"container_updater_sweep": 18.476239919662476})
def test_get_updater_info_object(self):
from_cache_response = {"object_updater_sweep": 0.79848217964172363}
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_updater_info('object')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['object_updater_sweep'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, {"object_updater_sweep": 0.79848217964172363})
self.assertEqual(rv, {"object_updater_sweep": 0.79848217964172363})
def test_get_expirer_info_object(self):
from_cache_response = {'object_expiration_pass': 0.79848217964172363,
@ -770,10 +770,10 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_expirer_info('object')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['object_expiration_pass', 'expired_last_pass'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, from_cache_response)
self.assertEqual(rv, from_cache_response)
def test_get_auditor_info_account(self):
from_cache_response = {"account_auditor_pass_completed": 0.24,
@ -783,13 +783,13 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_auditor_info('account')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['account_audits_passed',
'account_auditor_pass_completed',
'account_audits_since',
'account_audits_failed'],
'/var/cache/swift/account.recon'), {})])
self.assertEquals(rv, {"account_auditor_pass_completed": 0.24,
self.assertEqual(rv, {"account_auditor_pass_completed": 0.24,
"account_audits_failed": 0,
"account_audits_passed": 6,
"account_audits_since": "1333145374.1373529"})
@ -802,13 +802,13 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_auditor_info('container')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['container_audits_passed',
'container_auditor_pass_completed',
'container_audits_since',
'container_audits_failed'],
'/var/cache/swift/container.recon'), {})])
self.assertEquals(rv, {"container_auditor_pass_completed": 0.24,
self.assertEqual(rv, {"container_auditor_pass_completed": 0.24,
"container_audits_failed": 0,
"container_audits_passed": 6,
"container_audits_since": "1333145374.1373529"})
@ -832,11 +832,11 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_auditor_info('object')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['object_auditor_stats_ALL',
'object_auditor_stats_ZBF'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, {
self.assertEqual(rv, {
"object_auditor_stats_ALL": {
"audit_time": 115.14418768882751,
"bytes_processed": 234660,
@ -879,11 +879,11 @@ class TestReconSuccess(TestCase):
self.fakecache.fakeout_calls = []
self.fakecache.fakeout = from_cache_response
rv = self.app.get_auditor_info('object')
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['object_auditor_stats_ALL',
'object_auditor_stats_ZBF'],
'/var/cache/swift/object.recon'), {})])
self.assertEquals(rv, {
self.assertEqual(rv, {
"object_auditor_stats_ALL": {
'disk1': {
"audit_time": 115.14418768882751,
@ -913,26 +913,26 @@ class TestReconSuccess(TestCase):
self.mockos.ls_output = ['fakeone', 'faketwo']
self.mockos.ismount_output = False
rv = self.app.get_unmounted()
self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEquals(rv, unmounted_resp)
self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEqual(rv, unmounted_resp)
def test_get_unmounted_everything_normal(self):
unmounted_resp = []
self.mockos.ls_output = ['fakeone', 'faketwo']
self.mockos.ismount_output = True
rv = self.app.get_unmounted()
self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEquals(rv, unmounted_resp)
self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEqual(rv, unmounted_resp)
def test_get_unmounted_checkmount_fail(self):
unmounted_resp = [{'device': 'fakeone', 'mounted': 'brokendrive'}]
self.mockos.ls_output = ['fakeone']
self.mockos.ismount_output = OSError('brokendrive')
rv = self.app.get_unmounted()
self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEquals(self.mockos.ismount_calls,
self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEqual(self.mockos.ismount_calls,
[(('/srv/node/fakeone',), {})])
self.assertEquals(rv, unmounted_resp)
self.assertEqual(rv, unmounted_resp)
def test_no_get_unmounted(self):
@ -943,8 +943,8 @@ class TestReconSuccess(TestCase):
self.mockos.ls_output = []
self.mockos.ismount_output = False
rv = self.app.get_unmounted()
self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEquals(rv, unmounted_resp)
self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEqual(rv, unmounted_resp)
def test_get_diskusage(self):
# posix.statvfs_result(f_bsize=4096, f_frsize=4096, f_blocks=1963185,
@ -960,9 +960,9 @@ class TestReconSuccess(TestCase):
self.mockos.statvfs_output = statvfs_content
self.mockos.ismount_output = True
rv = self.app.get_diskusage()
self.assertEquals(self.mockos.statvfs_calls,
self.assertEqual(self.mockos.statvfs_calls,
[(('/srv/node/canhazdrive1',), {})])
self.assertEquals(rv, du_resp)
self.assertEqual(rv, du_resp)
def test_get_diskusage_checkmount_fail(self):
du_resp = [{'device': 'canhazdrive1', 'avail': '',
@ -970,10 +970,10 @@ class TestReconSuccess(TestCase):
self.mockos.ls_output = ['canhazdrive1']
self.mockos.ismount_output = OSError('brokendrive')
rv = self.app.get_diskusage()
self.assertEquals(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEquals(self.mockos.ismount_calls,
self.assertEqual(self.mockos.listdir_calls, [(('/srv/node',), {})])
self.assertEqual(self.mockos.ismount_calls,
[(('/srv/node/canhazdrive1',), {})])
self.assertEquals(rv, du_resp)
self.assertEqual(rv, du_resp)
@mock.patch("swift.common.middleware.recon.check_mount", fake_check_mount)
def test_get_diskusage_oserror(self):
@ -981,7 +981,7 @@ class TestReconSuccess(TestCase):
'mounted': 'Input/Output Error', 'used': '', 'size': ''}]
self.mockos.ls_output = ['canhazdrive1']
rv = self.app.get_diskusage()
self.assertEquals(rv, du_resp)
self.assertEqual(rv, du_resp)
def test_get_quarantine_count(self):
dirs = [['sda'], ['accounts', 'containers', 'objects', 'objects-1']]
@ -1003,7 +1003,7 @@ class TestReconSuccess(TestCase):
with mock.patch("os.path.exists", fake_exists):
with mock.patch("os.listdir", fake_listdir):
rv = self.app.get_quarantine_count()
self.assertEquals(rv, {'objects': 4, 'accounts': 2, 'policies':
self.assertEqual(rv, {'objects': 4, 'accounts': 2, 'policies':
{'1': {'objects': 2}, '0': {'objects': 2}},
'containers': 2})
@ -1015,7 +1015,7 @@ class TestReconSuccess(TestCase):
'']
oart = OpenAndReadTester(sockstat_content)
self.app.get_socket_info(openr=oart.open)
self.assertEquals(oart.open_calls, [
self.assertEqual(oart.open_calls, [
(('/proc/net/sockstat', 'r'), {}),
(('/proc/net/sockstat6', 'r'), {})])
@ -1023,10 +1023,10 @@ class TestReconSuccess(TestCase):
from_cache_response = {'drive_audit_errors': 7}
self.fakecache.fakeout = from_cache_response
rv = self.app.get_driveaudit_error()
self.assertEquals(self.fakecache.fakeout_calls,
self.assertEqual(self.fakecache.fakeout_calls,
[((['drive_audit_errors'],
'/var/cache/swift/drive.recon'), {})])
self.assertEquals(rv, {'drive_audit_errors': 7})
self.assertEqual(rv, {'drive_audit_errors': 7})
def test_get_time(self):
def fake_time():
@ -1035,7 +1035,7 @@ class TestReconSuccess(TestCase):
with mock.patch("time.time", fake_time):
now = fake_time()
rv = self.app.get_time()
self.assertEquals(rv, now)
self.assertEqual(rv, now)
class TestReconMiddleware(unittest.TestCase):
@ -1072,40 +1072,40 @@ class TestReconMiddleware(unittest.TestCase):
get_mem_resp = ['{"memtest": "1"}']
req = Request.blank('/recon/mem', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_mem_resp)
self.assertEqual(resp, get_mem_resp)
def test_recon_get_version(self):
req = Request.blank('/recon/version',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, [utils.json.dumps({'version': swiftver})])
self.assertEqual(resp, [utils.json.dumps({'version': swiftver})])
def test_recon_get_load(self):
get_load_resp = ['{"loadtest": "1"}']
req = Request.blank('/recon/load', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_load_resp)
self.assertEqual(resp, get_load_resp)
def test_recon_get_async(self):
get_async_resp = ['{"asynctest": "1"}']
req = Request.blank('/recon/async', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_async_resp)
self.assertEqual(resp, get_async_resp)
def test_get_device_info(self):
get_device_resp = ['{"/srv/1/node": ["sdb1"]}']
req = Request.blank('/recon/devices',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_device_resp)
self.assertEqual(resp, get_device_resp)
def test_recon_get_replication_notype(self):
get_replication_resp = ['{"replicationtest": "1"}']
req = Request.blank('/recon/replication',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_replication_resp)
self.assertEquals(self.frecon.fake_replication_rtype, 'object')
self.assertEqual(resp, get_replication_resp)
self.assertEqual(self.frecon.fake_replication_rtype, 'object')
self.frecon.fake_replication_rtype = None
def test_recon_get_replication_all(self):
@ -1114,22 +1114,22 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/replication/account',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_replication_resp)
self.assertEquals(self.frecon.fake_replication_rtype, 'account')
self.assertEqual(resp, get_replication_resp)
self.assertEqual(self.frecon.fake_replication_rtype, 'account')
self.frecon.fake_replication_rtype = None
# test container
req = Request.blank('/recon/replication/container',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_replication_resp)
self.assertEquals(self.frecon.fake_replication_rtype, 'container')
self.assertEqual(resp, get_replication_resp)
self.assertEqual(self.frecon.fake_replication_rtype, 'container')
self.frecon.fake_replication_rtype = None
# test object
req = Request.blank('/recon/replication/object',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_replication_resp)
self.assertEquals(self.frecon.fake_replication_rtype, 'object')
self.assertEqual(resp, get_replication_resp)
self.assertEqual(self.frecon.fake_replication_rtype, 'object')
self.frecon.fake_replication_rtype = None
def test_recon_get_auditor_invalid(self):
@ -1137,34 +1137,34 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/auditor/invalid',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_auditor_resp)
self.assertEqual(resp, get_auditor_resp)
def test_recon_get_auditor_notype(self):
get_auditor_resp = ['Invalid path: /recon/auditor']
req = Request.blank('/recon/auditor',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_auditor_resp)
self.assertEqual(resp, get_auditor_resp)
def test_recon_get_auditor_all(self):
get_auditor_resp = ['{"auditortest": "1"}']
req = Request.blank('/recon/auditor/account',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_auditor_resp)
self.assertEquals(self.frecon.fake_auditor_rtype, 'account')
self.assertEqual(resp, get_auditor_resp)
self.assertEqual(self.frecon.fake_auditor_rtype, 'account')
self.frecon.fake_auditor_rtype = None
req = Request.blank('/recon/auditor/container',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_auditor_resp)
self.assertEquals(self.frecon.fake_auditor_rtype, 'container')
self.assertEqual(resp, get_auditor_resp)
self.assertEqual(self.frecon.fake_auditor_rtype, 'container')
self.frecon.fake_auditor_rtype = None
req = Request.blank('/recon/auditor/object',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_auditor_resp)
self.assertEquals(self.frecon.fake_auditor_rtype, 'object')
self.assertEqual(resp, get_auditor_resp)
self.assertEqual(self.frecon.fake_auditor_rtype, 'object')
self.frecon.fake_auditor_rtype = None
def test_recon_get_updater_invalid(self):
@ -1172,28 +1172,28 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/updater/invalid',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_updater_resp)
self.assertEqual(resp, get_updater_resp)
def test_recon_get_updater_notype(self):
get_updater_resp = ['Invalid path: /recon/updater']
req = Request.blank('/recon/updater',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_updater_resp)
self.assertEqual(resp, get_updater_resp)
def test_recon_get_updater(self):
get_updater_resp = ['{"updatertest": "1"}']
req = Request.blank('/recon/updater/container',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(self.frecon.fake_updater_rtype, 'container')
self.assertEqual(self.frecon.fake_updater_rtype, 'container')
self.frecon.fake_updater_rtype = None
self.assertEquals(resp, get_updater_resp)
self.assertEqual(resp, get_updater_resp)
req = Request.blank('/recon/updater/object',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_updater_resp)
self.assertEquals(self.frecon.fake_updater_rtype, 'object')
self.assertEqual(resp, get_updater_resp)
self.assertEqual(self.frecon.fake_updater_rtype, 'object')
self.frecon.fake_updater_rtype = None
def test_recon_get_expirer_invalid(self):
@ -1201,22 +1201,22 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/expirer/invalid',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_updater_resp)
self.assertEqual(resp, get_updater_resp)
def test_recon_get_expirer_notype(self):
get_updater_resp = ['Invalid path: /recon/expirer']
req = Request.blank('/recon/expirer',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_updater_resp)
self.assertEqual(resp, get_updater_resp)
def test_recon_get_expirer_object(self):
get_expirer_resp = ['{"expirertest": "1"}']
req = Request.blank('/recon/expirer/object',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_expirer_resp)
self.assertEquals(self.frecon.fake_expirer_rtype, 'object')
self.assertEqual(resp, get_expirer_resp)
self.assertEqual(self.frecon.fake_expirer_rtype, 'object')
self.frecon.fake_updater_rtype = None
def test_recon_get_mounted(self):
@ -1224,7 +1224,7 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/mounted',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_mounted_resp)
self.assertEqual(resp, get_mounted_resp)
def test_recon_get_unmounted(self):
get_unmounted_resp = ['{"unmountedtest": "1"}']
@ -1232,7 +1232,7 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/unmounted',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_unmounted_resp)
self.assertEqual(resp, get_unmounted_resp)
def test_recon_no_get_unmounted(self):
get_unmounted_resp = '[]'
@ -1240,73 +1240,73 @@ class TestReconMiddleware(unittest.TestCase):
req = Request.blank('/recon/unmounted',
environ={'REQUEST_METHOD': 'GET'})
resp = ''.join(self.app(req.environ, start_response))
self.assertEquals(resp, get_unmounted_resp)
self.assertEqual(resp, get_unmounted_resp)
def test_recon_get_diskusage(self):
get_diskusage_resp = ['{"diskusagetest": "1"}']
req = Request.blank('/recon/diskusage',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_diskusage_resp)
self.assertEqual(resp, get_diskusage_resp)
def test_recon_get_ringmd5(self):
get_ringmd5_resp = ['{"ringmd5test": "1"}']
req = Request.blank('/recon/ringmd5',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_ringmd5_resp)
self.assertEqual(resp, get_ringmd5_resp)
def test_recon_get_swiftconfmd5(self):
get_swiftconfmd5_resp = ['{"/etc/swift/swift.conf": "abcdef"}']
req = Request.blank('/recon/swiftconfmd5',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_swiftconfmd5_resp)
self.assertEqual(resp, get_swiftconfmd5_resp)
def test_recon_get_quarantined(self):
get_quarantined_resp = ['{"quarantinedtest": "1"}']
req = Request.blank('/recon/quarantined',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_quarantined_resp)
self.assertEqual(resp, get_quarantined_resp)
def test_recon_get_sockstat(self):
get_sockstat_resp = ['{"sockstattest": "1"}']
req = Request.blank('/recon/sockstat',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_sockstat_resp)
self.assertEqual(resp, get_sockstat_resp)
def test_recon_invalid_path(self):
req = Request.blank('/recon/invalid',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, ['Invalid path: /recon/invalid'])
self.assertEqual(resp, ['Invalid path: /recon/invalid'])
def test_no_content(self):
self.app.get_load = self.frecon.nocontent
req = Request.blank('/recon/load', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, ['Internal server error.'])
self.assertEqual(resp, ['Internal server error.'])
def test_recon_pass(self):
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, 'FAKE APP')
self.assertEqual(resp, 'FAKE APP')
def test_recon_get_driveaudit(self):
get_driveaudit_resp = ['{"driveaudittest": "1"}']
req = Request.blank('/recon/driveaudit',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_driveaudit_resp)
self.assertEqual(resp, get_driveaudit_resp)
def test_recon_get_time(self):
get_time_resp = ['{"timetest": "1"}']
req = Request.blank('/recon/time',
environ={'REQUEST_METHOD': 'GET'})
resp = self.app(req.environ, start_response)
self.assertEquals(resp, get_time_resp)
self.assertEqual(resp, get_time_resp)
if __name__ == '__main__':
unittest.main()

View File

@ -108,8 +108,8 @@ class TestSloMiddleware(SloTestCase):
def test_handle_multipart_no_obj(self):
req = Request.blank('/')
resp_iter = self.slo(req.environ, fake_start_response)
self.assertEquals(self.app.calls, [('GET', '/')])
self.assertEquals(''.join(resp_iter), 'passed')
self.assertEqual(self.app.calls, [('GET', '/')])
self.assertEqual(''.join(resp_iter), 'passed')
def test_slo_header_assigned(self):
req = Request.blank(
@ -132,15 +132,15 @@ class TestSloMiddleware(SloTestCase):
data = json.dumps(
[{'path': '/cont/object', 'etag': 'etagoftheobjecitsegment',
'size_bytes': 100}])
self.assertEquals('/cont/object',
self.assertEqual('/cont/object',
slo.parse_input(data)[0]['path'])
data = json.dumps(
[{'path': '/cont/object', 'etag': 'etagoftheobjecitsegment',
'size_bytes': 100, 'range': '0-40,30-90'}])
parsed = slo.parse_input(data)
self.assertEquals('/cont/object', parsed[0]['path'])
self.assertEquals([(0, 40), (30, 90)], parsed[0]['range'].ranges)
self.assertEqual('/cont/object', parsed[0]['path'])
self.assertEqual([(0, 40), (30, 90)], parsed[0]['range'].ranges)
class TestSloPutManifest(SloTestCase):
@ -213,7 +213,7 @@ class TestSloPutManifest(SloTestCase):
self.slo.handle_multipart_put(req, fake_start_response)
except HTTPException as e:
pass
self.assertEquals(e.status_int, 413)
self.assertEqual(e.status_int, 413)
with patch.object(self.slo, 'max_manifest_segments', 0):
req = Request.blank('/v1/a/c/o', body=test_json_data)
@ -222,7 +222,7 @@ class TestSloPutManifest(SloTestCase):
self.slo.handle_multipart_put(req, fake_start_response)
except HTTPException as e:
pass
self.assertEquals(e.status_int, 413)
self.assertEqual(e.status_int, 413)
with patch.object(self.slo, 'min_segment_size', 1000):
test_json_data_2obj = json.dumps(
@ -237,20 +237,20 @@ class TestSloPutManifest(SloTestCase):
self.slo.handle_multipart_put(req, fake_start_response)
except HTTPException as e:
pass
self.assertEquals(e.status_int, 400)
self.assertEqual(e.status_int, 400)
req = Request.blank('/v1/a/c/o', headers={'X-Copy-From': 'lala'})
try:
self.slo.handle_multipart_put(req, fake_start_response)
except HTTPException as e:
pass
self.assertEquals(e.status_int, 405)
self.assertEqual(e.status_int, 405)
# ignores requests to /
req = Request.blank(
'/?multipart-manifest=put',
environ={'REQUEST_METHOD': 'PUT'}, body=test_json_data)
self.assertEquals(
self.assertEqual(
list(self.slo.handle_multipart_put(req, fake_start_response)),
['passed'])
@ -310,7 +310,7 @@ class TestSloPutManifest(SloTestCase):
self.slo.handle_multipart_put(req, fake_start_response)
except HTTPException as e:
pass
self.assertEquals(e.status_int, 400)
self.assertEqual(e.status_int, 400)
def test_handle_multipart_put_success_unicode(self):
test_json_data = json.dumps([{'path': u'/cont/object\u2661',
@ -331,7 +331,7 @@ class TestSloPutManifest(SloTestCase):
environ={'REQUEST_METHOD': 'PUT'}, headers={'Accept': 'test'},
body=test_xml_data)
no_xml = self.slo(req.environ, fake_start_response)
self.assertEquals(no_xml, ['Manifest must be valid json.'])
self.assertEqual(no_xml, ['Manifest must be valid json.'])
def test_handle_multipart_put_bad_data(self):
bad_data = json.dumps([{'path': '/cont/object',
@ -374,7 +374,7 @@ class TestSloPutManifest(SloTestCase):
'/v1/AUTH_test/checktest/man_3?multipart-manifest=put',
environ={'REQUEST_METHOD': 'PUT'}, body=good_data)
status, headers, body = self.call_slo(req)
self.assertEquals(self.app.call_count, 3)
self.assertEqual(self.app.call_count, 3)
# go behind SLO's back and see what actually got stored
req = Request.blank(
@ -386,9 +386,9 @@ class TestSloPutManifest(SloTestCase):
headers = dict(headers)
manifest_data = json.loads(body)
self.assertTrue(headers['Content-Type'].endswith(';swift_bytes=3'))
self.assertEquals(len(manifest_data), 2)
self.assertEquals(manifest_data[0]['hash'], 'a')
self.assertEquals(manifest_data[0]['bytes'], 1)
self.assertEqual(len(manifest_data), 2)
self.assertEqual(manifest_data[0]['hash'], 'a')
self.assertEqual(manifest_data[0]['bytes'], 1)
self.assertTrue(
not manifest_data[0]['last_modified'].startswith('2012'))
self.assertTrue(manifest_data[1]['last_modified'].startswith('2012'))
@ -407,19 +407,19 @@ class TestSloPutManifest(SloTestCase):
body=bad_data)
status, headers, body = self.call_slo(req)
self.assertEquals(self.app.call_count, 5)
self.assertEqual(self.app.call_count, 5)
errors = json.loads(body)['Errors']
self.assertEquals(len(errors), 5)
self.assertEquals(errors[0][0], '/checktest/a_1')
self.assertEquals(errors[0][1], 'Size Mismatch')
self.assertEquals(errors[1][0], '/checktest/badreq')
self.assertEquals(errors[1][1], '400 Bad Request')
self.assertEquals(errors[2][0], '/checktest/b_2')
self.assertEquals(errors[2][1], 'Etag Mismatch')
self.assertEquals(errors[3][0], '/checktest/slob')
self.assertEquals(errors[3][1], 'Size Mismatch')
self.assertEquals(errors[4][0], '/checktest/slob')
self.assertEquals(errors[4][1], 'Etag Mismatch')
self.assertEqual(len(errors), 5)
self.assertEqual(errors[0][0], '/checktest/a_1')
self.assertEqual(errors[0][1], 'Size Mismatch')
self.assertEqual(errors[1][0], '/checktest/badreq')
self.assertEqual(errors[1][1], '400 Bad Request')
self.assertEqual(errors[2][0], '/checktest/b_2')
self.assertEqual(errors[2][1], 'Etag Mismatch')
self.assertEqual(errors[3][0], '/checktest/slob')
self.assertEqual(errors[3][1], 'Size Mismatch')
self.assertEqual(errors[4][0], '/checktest/slob')
self.assertEqual(errors[4][1], 'Etag Mismatch')
def test_handle_multipart_put_manifest_equal_slo(self):
test_json_data = json.dumps([{'path': '/cont/object',
@ -469,7 +469,7 @@ class TestSloPutManifest(SloTestCase):
'/v1/AUTH_test/checktest/man_3?multipart-manifest=put',
environ={'REQUEST_METHOD': 'PUT'}, body=good_data)
status, headers, body = self.call_slo(req)
self.assertEquals(self.app.call_count, 3)
self.assertEqual(self.app.call_count, 3)
# Check that we still populated the manifest properly from our HEADs
req = Request.blank(
@ -479,8 +479,8 @@ class TestSloPutManifest(SloTestCase):
environ={'REQUEST_METHOD': 'GET'})
status, headers, body = self.call_app(req)
manifest_data = json.loads(body)
self.assertEquals(1, manifest_data[0]['bytes'])
self.assertEquals(2, manifest_data[1]['bytes'])
self.assertEqual(1, manifest_data[0]['bytes'])
self.assertEqual(2, manifest_data[1]['bytes'])
def test_handle_multipart_put_skip_size_check_still_uses_min_size(self):
with patch.object(self.slo, 'min_segment_size', 50):
@ -493,7 +493,7 @@ class TestSloPutManifest(SloTestCase):
req = Request.blank('/v1/AUTH_test/c/o', body=test_json_data)
with self.assertRaises(HTTPException) as cm:
self.slo.handle_multipart_put(req, fake_start_response)
self.assertEquals(cm.exception.status_int, 400)
self.assertEqual(cm.exception.status_int, 400)
def test_handle_multipart_put_skip_etag_check(self):
good_data = json.dumps(
@ -503,7 +503,7 @@ class TestSloPutManifest(SloTestCase):
'/v1/AUTH_test/checktest/man_3?multipart-manifest=put',
environ={'REQUEST_METHOD': 'PUT'}, body=good_data)
status, headers, body = self.call_slo(req)
self.assertEquals(self.app.call_count, 3)
self.assertEqual(self.app.call_count, 3)
# Check that we still populated the manifest properly from our HEADs
req = Request.blank(
@ -513,8 +513,8 @@ class TestSloPutManifest(SloTestCase):
environ={'REQUEST_METHOD': 'GET'})
status, headers, body = self.call_app(req)
manifest_data = json.loads(body)
self.assertEquals('a', manifest_data[0]['hash'])
self.assertEquals('b', manifest_data[1]['hash'])
self.assertEqual('a', manifest_data[0]['hash'])
self.assertEqual('b', manifest_data[1]['hash'])
def test_handle_unsatisfiable_ranges(self):
bad_data = json.dumps(
@ -559,18 +559,18 @@ class TestSloPutManifest(SloTestCase):
environ={'REQUEST_METHOD': 'GET'})
status, headers, body = self.call_app(req)
manifest_data = json.loads(body)
self.assertEquals('a', manifest_data[0]['hash'])
self.assertEqual('a', manifest_data[0]['hash'])
self.assertNotIn('range', manifest_data[0])
self.assertNotIn('segment_bytes', manifest_data[0])
self.assertEquals('b', manifest_data[1]['hash'])
self.assertEquals('1-1', manifest_data[1]['range'])
self.assertEqual('b', manifest_data[1]['hash'])
self.assertEqual('1-1', manifest_data[1]['range'])
self.assertEquals('b', manifest_data[2]['hash'])
self.assertEquals('0-0', manifest_data[2]['range'])
self.assertEqual('b', manifest_data[2]['hash'])
self.assertEqual('0-0', manifest_data[2]['range'])
self.assertEquals('etagoftheobjectsegment', manifest_data[3]['hash'])
self.assertEquals('10-40', manifest_data[3]['range'])
self.assertEqual('etagoftheobjectsegment', manifest_data[3]['hash'])
self.assertEqual('10-40', manifest_data[3]['range'])
def test_handle_multiple_ranges_error(self):
good_data = json.dumps(
@ -585,7 +585,7 @@ class TestSloPutManifest(SloTestCase):
environ={'REQUEST_METHOD': 'PUT'}, body=good_data)
status, headers, body = self.call_slo(req)
self.assertEqual(status, '400 Bad Request')
self.assertEquals(self.app.call_count, 3)
self.assertEqual(self.app.call_count, 3)
self.assertEqual(body, '\n'.join([
'Errors:',
'/checktest/b_2, Multiple Ranges',
@ -707,7 +707,7 @@ class TestSloDeleteManifest(SloTestCase):
'/v1/AUTH_test/deltest/man',
environ={'REQUEST_METHOD': 'DELETE'})
self.slo(req.environ, fake_start_response)
self.assertEquals(self.app.call_count, 1)
self.assertEqual(self.app.call_count, 1)
def test_handle_multipart_delete_bad_utf8(self):
req = Request.blank(
@ -715,9 +715,9 @@ class TestSloDeleteManifest(SloTestCase):
environ={'REQUEST_METHOD': 'DELETE',
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
resp_data = json.loads(body)
self.assertEquals(resp_data['Response Status'],
self.assertEqual(resp_data['Response Status'],
'412 Precondition Failed')
def test_handle_multipart_delete_whole_404(self):
@ -727,15 +727,15 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET',
'/v1/AUTH_test/deltest/man_404?multipart-manifest=get')])
self.assertEquals(resp_data['Response Status'], '200 OK')
self.assertEquals(resp_data['Response Body'], '')
self.assertEquals(resp_data['Number Deleted'], 0)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEquals(resp_data['Errors'], [])
self.assertEqual(resp_data['Response Status'], '200 OK')
self.assertEqual(resp_data['Response Body'], '')
self.assertEqual(resp_data['Number Deleted'], 0)
self.assertEqual(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Errors'], [])
def test_handle_multipart_delete_segment_404(self):
req = Request.blank(
@ -744,7 +744,7 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET',
'/v1/AUTH_test/deltest/man?multipart-manifest=get'),
@ -754,16 +754,16 @@ class TestSloDeleteManifest(SloTestCase):
'/v1/AUTH_test/deltest/b_2?multipart-manifest=delete'),
('DELETE',
'/v1/AUTH_test/deltest/man?multipart-manifest=delete')])
self.assertEquals(resp_data['Response Status'], '200 OK')
self.assertEquals(resp_data['Number Deleted'], 2)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Response Status'], '200 OK')
self.assertEqual(resp_data['Number Deleted'], 2)
self.assertEqual(resp_data['Number Not Found'], 1)
def test_handle_multipart_delete_whole(self):
req = Request.blank(
'/v1/AUTH_test/deltest/man-all-there?multipart-manifest=delete',
environ={'REQUEST_METHOD': 'DELETE'})
self.call_slo(req)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET',
'/v1/AUTH_test/deltest/man-all-there?multipart-manifest=get'),
@ -778,7 +778,7 @@ class TestSloDeleteManifest(SloTestCase):
'multipart-manifest=delete',
environ={'REQUEST_METHOD': 'DELETE'})
self.call_slo(req)
self.assertEquals(
self.assertEqual(
set(self.app.calls),
set([('GET', '/v1/AUTH_test/deltest/' +
'manifest-with-submanifest?multipart-manifest=get'),
@ -807,10 +807,10 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
with patch.object(slo, 'MAX_BUFFERED_SLO_SEGMENTS', 1):
status, headers, body = self.call_slo(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
resp_data = json.loads(body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Response Body'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Response Body'],
'Too many buffered slo segments to delete.')
def test_handle_multipart_delete_nested_404(self):
@ -821,7 +821,7 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET', '/v1/AUTH_test/deltest/' +
'manifest-missing-submanifest?multipart-manifest=get'),
@ -831,11 +831,11 @@ class TestSloDeleteManifest(SloTestCase):
('DELETE', '/v1/AUTH_test/deltest/d_3?multipart-manifest=delete'),
('DELETE', '/v1/AUTH_test/deltest/' +
'manifest-missing-submanifest?multipart-manifest=delete')])
self.assertEquals(resp_data['Response Status'], '200 OK')
self.assertEquals(resp_data['Response Body'], '')
self.assertEquals(resp_data['Number Deleted'], 3)
self.assertEquals(resp_data['Number Not Found'], 1)
self.assertEquals(resp_data['Errors'], [])
self.assertEqual(resp_data['Response Status'], '200 OK')
self.assertEqual(resp_data['Response Body'], '')
self.assertEqual(resp_data['Number Deleted'], 3)
self.assertEqual(resp_data['Number Not Found'], 1)
self.assertEqual(resp_data['Errors'], [])
def test_handle_multipart_delete_nested_401(self):
self.app.register(
@ -848,10 +848,10 @@ class TestSloDeleteManifest(SloTestCase):
environ={'REQUEST_METHOD': 'DELETE',
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
resp_data = json.loads(body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Errors'],
[['/deltest/submanifest', '401 Unauthorized']])
def test_handle_multipart_delete_nested_500(self):
@ -865,10 +865,10 @@ class TestSloDeleteManifest(SloTestCase):
environ={'REQUEST_METHOD': 'DELETE',
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
resp_data = json.loads(body)
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Errors'],
[['/deltest/submanifest',
'Unable to load SLO manifest or segment.']])
@ -879,14 +879,14 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET', '/v1/AUTH_test/deltest/a_1?multipart-manifest=get')])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Response Body'], '')
self.assertEquals(resp_data['Number Deleted'], 0)
self.assertEquals(resp_data['Number Not Found'], 0)
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Response Body'], '')
self.assertEqual(resp_data['Number Deleted'], 0)
self.assertEqual(resp_data['Number Not Found'], 0)
self.assertEqual(resp_data['Errors'],
[['/deltest/a_1', 'Not an SLO manifest']])
def test_handle_multipart_delete_bad_json(self):
@ -896,14 +896,14 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(self.app.calls,
self.assertEqual(self.app.calls,
[('GET', '/v1/AUTH_test/deltest/' +
'manifest-badjson?multipart-manifest=get')])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Response Body'], '')
self.assertEquals(resp_data['Number Deleted'], 0)
self.assertEquals(resp_data['Number Not Found'], 0)
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Response Body'], '')
self.assertEqual(resp_data['Number Deleted'], 0)
self.assertEqual(resp_data['Number Not Found'], 0)
self.assertEqual(resp_data['Errors'],
[['/deltest/manifest-badjson',
'Unable to load SLO manifest']])
@ -915,7 +915,7 @@ class TestSloDeleteManifest(SloTestCase):
'HTTP_ACCEPT': 'application/json'})
status, headers, body = self.call_slo(req)
resp_data = json.loads(body)
self.assertEquals(
self.assertEqual(
self.app.calls,
[('GET', '/v1/AUTH_test/deltest/' +
'manifest-with-unauth-segment?multipart-manifest=get'),
@ -924,11 +924,11 @@ class TestSloDeleteManifest(SloTestCase):
'q_17?multipart-manifest=delete'),
('DELETE', '/v1/AUTH_test/deltest/' +
'manifest-with-unauth-segment?multipart-manifest=delete')])
self.assertEquals(resp_data['Response Status'], '400 Bad Request')
self.assertEquals(resp_data['Response Body'], '')
self.assertEquals(resp_data['Number Deleted'], 2)
self.assertEquals(resp_data['Number Not Found'], 0)
self.assertEquals(resp_data['Errors'],
self.assertEqual(resp_data['Response Status'], '400 Bad Request')
self.assertEqual(resp_data['Response Body'], '')
self.assertEqual(resp_data['Number Deleted'], 2)
self.assertEqual(resp_data['Number Not Found'], 0)
self.assertEqual(resp_data['Errors'],
[['/deltest-unauth/q_17', '401 Unauthorized']])

View File

@ -393,117 +393,117 @@ class TestStaticWeb(unittest.TestCase):
def test_app_set(self):
app = FakeApp()
sw = staticweb.filter_factory({})(app)
self.assertEquals(sw.app, app)
self.assertEqual(sw.app, app)
def test_conf_set(self):
conf = {'blah': 1}
sw = staticweb.filter_factory(conf)(FakeApp())
self.assertEquals(sw.conf, conf)
self.assertEqual(sw.conf, conf)
def test_root(self):
resp = Request.blank('/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_version(self):
resp = Request.blank('/v1').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 412)
self.assertEqual(resp.status_int, 412)
def test_account(self):
resp = Request.blank('/v1/a').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
def test_container1(self):
resp = Request.blank('/v1/a/c1').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
def test_container1_web_mode_explicitly_off(self):
resp = Request.blank('/v1/a/c1',
headers={'x-web-mode': 'false'}).get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
def test_container1_web_mode_explicitly_on(self):
resp = Request.blank('/v1/a/c1',
headers={'x-web-mode': 'true'}).get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container2(self):
resp = Request.blank('/v1/a/c2').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'text/plain')
self.assertEquals(len(resp.body.split('\n')),
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'text/plain')
self.assertEqual(len(resp.body.split('\n')),
int(resp.headers['x-container-object-count']))
def test_container2_web_mode_explicitly_off(self):
resp = Request.blank(
'/v1/a/c2',
headers={'x-web-mode': 'false'}).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'text/plain')
self.assertEquals(len(resp.body.split('\n')),
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'text/plain')
self.assertEqual(len(resp.body.split('\n')),
int(resp.headers['x-container-object-count']))
def test_container2_web_mode_explicitly_on(self):
resp = Request.blank(
'/v1/a/c2',
headers={'x-web-mode': 'true'}).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container2onetxt(self):
resp = Request.blank(
'/v1/a/c2/one.txt').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container2json(self):
resp = Request.blank(
'/v1/a/c2?format=json').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(len(json.loads(resp.body)),
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(len(json.loads(resp.body)),
int(resp.headers['x-container-object-count']))
def test_container2json_web_mode_explicitly_off(self):
resp = Request.blank(
'/v1/a/c2?format=json',
headers={'x-web-mode': 'false'}).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.content_type, 'application/json')
self.assertEquals(len(json.loads(resp.body)),
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.content_type, 'application/json')
self.assertEqual(len(json.loads(resp.body)),
int(resp.headers['x-container-object-count']))
def test_container2json_web_mode_explicitly_on(self):
resp = Request.blank(
'/v1/a/c2?format=json',
headers={'x-web-mode': 'true'}).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container3(self):
resp = Request.blank('/v1/a/c3').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEquals(resp.headers['location'],
self.assertEqual(resp.status_int, 301)
self.assertEqual(resp.headers['location'],
'http://localhost/v1/a/c3/')
def test_container3indexhtml(self):
resp = Request.blank('/v1/a/c3/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Test main index.html file.' in resp.body)
def test_container3subsubdir(self):
resp = Request.blank(
'/v1/a/c3/subdir3/subsubdir').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEqual(resp.status_int, 301)
def test_container3subsubdircontents(self):
resp = Request.blank(
'/v1/a/c3/subdir3/subsubdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.body, 'index file')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.body, 'index file')
def test_container3subdir(self):
resp = Request.blank(
'/v1/a/c3/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c3/subdir/' in resp.body)
self.assertTrue('</style>' in resp.body)
self.assertTrue('<link' not in resp.body)
@ -512,100 +512,100 @@ class TestStaticWeb(unittest.TestCase):
def test_container3subdirx(self):
resp = Request.blank(
'/v1/a/c3/subdirx/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container3subdiry(self):
resp = Request.blank(
'/v1/a/c3/subdiry/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_container3subdirz(self):
resp = Request.blank(
'/v1/a/c3/subdirz').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEqual(resp.status_int, 301)
def test_container3unknown(self):
resp = Request.blank(
'/v1/a/c3/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
def test_container3bindexhtml(self):
resp = Request.blank('/v1/a/c3b/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 204)
self.assertEquals(resp.body, '')
self.assertEqual(resp.status_int, 204)
self.assertEqual(resp.body, '')
def test_container4indexhtml(self):
resp = Request.blank('/v1/a/c4/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c4/' in resp.body)
self.assertTrue('href="listing.css"' in resp.body)
def test_container4indexhtmlauthed(self):
resp = Request.blank('/v1/a/c4').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEqual(resp.status_int, 301)
resp = Request.blank(
'/v1/a/c4',
environ={'REMOTE_USER': 'authed'}).get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
resp = Request.blank(
'/v1/a/c4', headers={'x-web-mode': 't'},
environ={'REMOTE_USER': 'authed'}).get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEqual(resp.status_int, 301)
def test_container4unknown(self):
resp = Request.blank(
'/v1/a/c4/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue("Chrome's 404 fancy-page sucks." in resp.body)
def test_container4subdir(self):
resp = Request.blank(
'/v1/a/c4/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c4/subdir/' in resp.body)
self.assertTrue('</style>' not in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="../listing.css"' in resp.body)
self.assertEquals(resp.headers['content-type'],
self.assertEqual(resp.headers['content-type'],
'text/html; charset=UTF-8')
def test_container4onetxt(self):
resp = Request.blank(
'/v1/a/c4/one.txt').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_container4twotxt(self):
resp = Request.blank(
'/v1/a/c4/two.txt').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 503)
self.assertEqual(resp.status_int, 503)
def test_container5indexhtml(self):
resp = Request.blank('/v1/a/c5/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 503)
self.assertEqual(resp.status_int, 503)
def test_container5unknown(self):
resp = Request.blank(
'/v1/a/c5/unknown').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue("Chrome's 404 fancy-page sucks." not in resp.body)
def test_container6subdir(self):
resp = Request.blank(
'/v1/a/c6/subdir').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 301)
self.assertEqual(resp.status_int, 301)
def test_container7listing(self):
resp = Request.blank('/v1/a/c7/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('Web Listing Disabled' in resp.body)
def test_container8listingcss(self):
resp = Request.blank(
'/v1/a/c8/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c8/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue(
@ -614,7 +614,7 @@ class TestStaticWeb(unittest.TestCase):
def test_container8subdirlistingcss(self):
resp = Request.blank(
'/v1/a/c8/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c8/subdir/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue(
@ -623,7 +623,7 @@ class TestStaticWeb(unittest.TestCase):
def test_container9listingcss(self):
resp = Request.blank(
'/v1/a/c9/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c9/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="/absolute/listing.css"' in resp.body)
@ -631,7 +631,7 @@ class TestStaticWeb(unittest.TestCase):
def test_container9subdirlistingcss(self):
resp = Request.blank(
'/v1/a/c9/subdir/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c9/subdir/' in resp.body)
self.assertTrue('<link' in resp.body)
self.assertTrue('href="/absolute/listing.css"' in resp.body)
@ -639,67 +639,67 @@ class TestStaticWeb(unittest.TestCase):
def test_container10unicodesubdirlisting(self):
resp = Request.blank(
'/v1/a/c10/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c10/' in resp.body)
resp = Request.blank(
'/v1/a/c10/\xe2\x98\x83/').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('Listing of /v1/a/c10/\xe2\x98\x83/' in resp.body)
resp = Request.blank(
'/v1/a/c10/\xe2\x98\x83/\xe2\x98\x83/'
).get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue(
'Listing of /v1/a/c10/\xe2\x98\x83/\xe2\x98\x83/' in resp.body)
def test_container11subdirmarkerobjectindex(self):
resp = Request.blank('/v1/a/c11/subdir/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('<h2>c11 subdir index</h2>' in resp.body)
def test_container11subdirmarkermatchdirtype(self):
resp = Request.blank('/v1/a/c11a/subdir/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('Index File Not Found' in resp.body)
def test_container11subdirmarkeraltdirtype(self):
resp = Request.blank('/v1/a/c11a/subdir2/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_container11subdirmarkerinvaliddirtype(self):
resp = Request.blank('/v1/a/c11a/subdir3/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_container12unredirectedrequest(self):
resp = Request.blank('/v1/a/c12/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('index file' in resp.body)
def test_container_404_has_css(self):
resp = Request.blank('/v1/a/c13/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('listing.css' in resp.body)
def test_container_404_has_no_css(self):
resp = Request.blank('/v1/a/c7/').get_response(
self.test_staticweb)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('listing.css' not in resp.body)
self.assertTrue('<style' in resp.body)
def test_subrequest_once_if_possible(self):
resp = Request.blank(
'/v1/a/c4/one.txt').get_response(self.test_staticweb)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['x-object-meta-test'], 'value')
self.assertEquals(resp.body, '1')
self.assertEquals(self.app.calls, 1)
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['x-object-meta-test'], 'value')
self.assertEqual(resp.body, '1')
self.assertEqual(self.app.calls, 1)
if __name__ == '__main__':

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ class TestTempURL(unittest.TestCase):
def test_passthrough(self):
resp = self._make_request('/v1/a/c/o').get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' not in resp.body)
def test_allow_options(self):
@ -120,7 +120,7 @@ class TestTempURL(unittest.TestCase):
resp = self._make_request(
'/v1/a/c/o?temp_url_sig=abcde&temp_url_expires=12345',
environ={'REQUEST_METHOD': 'OPTIONS'}).get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def assert_valid_sig(self, expires, path, keys, sig, environ=None):
if not environ:
@ -130,11 +130,11 @@ class TestTempURL(unittest.TestCase):
req = self._make_request(path, keys=keys, environ=environ)
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'],
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'],
'attachment; filename="o"; ' + "filename*=UTF-8''o")
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_get_valid(self):
method = 'GET'
@ -192,12 +192,12 @@ class TestTempURL(unittest.TestCase):
'filename=bob%%20%%22killer%%22.txt' % (sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'],
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'],
'attachment; filename="bob %22killer%22.txt"; ' +
"filename*=UTF-8''bob%20%22killer%22.txt")
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_head_valid(self):
method = 'HEAD'
@ -212,7 +212,7 @@ class TestTempURL(unittest.TestCase):
% (sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
def test_get_valid_with_filename_and_inline(self):
method = 'GET'
@ -226,10 +226,10 @@ class TestTempURL(unittest.TestCase):
'filename=bob%%20%%22killer%%22.txt&inline=' % (sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'], 'inline')
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'], 'inline')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_get_valid_with_inline(self):
method = 'GET'
@ -243,10 +243,10 @@ class TestTempURL(unittest.TestCase):
'inline=' % (sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'], 'inline')
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'], 'inline')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_obj_odd_chars(self):
method = 'GET'
@ -260,12 +260,12 @@ class TestTempURL(unittest.TestCase):
sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'],
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'],
'attachment; filename="a%0D%0Ab"; ' +
"filename*=UTF-8''a%0D%0Ab")
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_obj_odd_chars_in_content_disposition_metadata(self):
method = 'GET'
@ -280,11 +280,11 @@ class TestTempURL(unittest.TestCase):
headers = [('Content-Disposition', 'attachment; filename="fu\nbar"')]
self.tempurl.app = FakeApp(iter([('200 Ok', headers, '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'],
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'],
'attachment; filename="fu%0Abar"')
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_obj_trailing_slash(self):
method = 'GET'
@ -298,12 +298,12 @@ class TestTempURL(unittest.TestCase):
sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.headers['content-disposition'],
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.headers['content-disposition'],
'attachment; filename="o"; ' +
"filename*=UTF-8''o")
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_filename_trailing_slash(self):
method = 'GET'
@ -317,13 +317,13 @@ class TestTempURL(unittest.TestCase):
'filename=/i/want/this/just/as/it/is/' % (sig, expires)})
self.tempurl.app = FakeApp(iter([('200 Ok', (), '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEquals(
self.assertEqual(resp.status_int, 200)
self.assertEqual(
resp.headers['content-disposition'],
'attachment; filename="/i/want/this/just/as/it/is/"; ' +
"filename*=UTF-8''/i/want/this/just/as/it/is/")
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_get_valid_but_404(self):
method = 'GET'
@ -337,10 +337,10 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertFalse('content-disposition' in resp.headers)
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_put_not_allowed_by_get(self):
method = 'GET'
@ -355,7 +355,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -372,9 +372,9 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 404)
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_get_not_allowed_by_put(self):
method = 'PUT'
@ -388,7 +388,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -403,7 +403,7 @@ class TestTempURL(unittest.TestCase):
path, keys=[key],
environ={'QUERY_STRING': 'temp_url_expires=%s' % expires})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -418,7 +418,7 @@ class TestTempURL(unittest.TestCase):
path, keys=[key],
environ={'QUERY_STRING': 'temp_url_sig=%s' % sig})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -434,7 +434,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -450,7 +450,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -467,9 +467,9 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 404)
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_head_allowed_by_put(self):
method = 'PUT'
@ -484,9 +484,9 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 404)
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_head_allowed_by_post(self):
method = 'POST'
@ -501,9 +501,9 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEquals(req.environ['swift.authorize_override'], True)
self.assertEquals(req.environ['REMOTE_USER'], '.wsgi.tempurl')
self.assertEqual(resp.status_int, 404)
self.assertEqual(req.environ['swift.authorize_override'], True)
self.assertEqual(req.environ['REMOTE_USER'], '.wsgi.tempurl')
def test_head_otherwise_not_allowed(self):
method = 'PUT'
@ -521,7 +521,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Www-Authenticate' in resp.headers)
def test_post_when_forbidden_by_config(self):
@ -538,7 +538,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -556,7 +556,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -573,7 +573,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
def test_unknown_not_allowed(self):
method = 'UNKNOWN'
@ -588,7 +588,7 @@ class TestTempURL(unittest.TestCase):
'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -615,7 +615,7 @@ class TestTempURL(unittest.TestCase):
# make request will setup the environ cache for us
req = self._make_request(path + qs, **key_kwargs)
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404) # sanity check
self.assertEqual(resp.status_int, 404) # sanity check
authorize = req.environ['swift.authorize']
# Requests for other objects happen if, for example, you're
@ -636,7 +636,7 @@ class TestTempURL(unittest.TestCase):
req = self._make_request(path + qs, **key_kwargs)
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404) # sanity check
self.assertEqual(resp.status_int, 404) # sanity check
authorize = req.environ['swift.authorize']
oo_resp = authorize(req_other_object)
@ -657,7 +657,7 @@ class TestTempURL(unittest.TestCase):
req = self._make_request(path + qs, **key_kwargs)
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404) # sanity check
self.assertEqual(resp.status_int, 404) # sanity check
authorize = req.environ['swift.authorize']
oo_resp = authorize(req_other_object)
@ -679,7 +679,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -699,7 +699,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -715,7 +715,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires + 1)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -731,7 +731,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
@ -749,7 +749,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s'
% (sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 400)
self.assertEqual(resp.status_int, 400)
self.assertTrue('header' in resp.body)
self.assertTrue('not allowed' in resp.body)
self.assertTrue('X-Object-Manifest' in resp.body)
@ -769,7 +769,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('x-remove-this' not in self.app.request.headers)
def test_removed_incoming_headers_match(self):
@ -789,9 +789,9 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('x-remove-this-one' not in self.app.request.headers)
self.assertEquals(
self.assertEqual(
self.app.request.headers['x-remove-this-except-this'], 'value2')
def test_allow_trumps_incoming_header_conflict(self):
@ -810,7 +810,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('x-conflict-header' in self.app.request.headers)
def test_allow_trumps_incoming_header_startswith_conflict(self):
@ -829,7 +829,7 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('x-conflict-header-test' in self.app.request.headers)
def test_removed_outgoing_header(self):
@ -846,9 +846,9 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
self.assertTrue('x-test-header-one-a' not in resp.headers)
self.assertEquals(resp.headers['x-test-header-two-a'], 'value2')
self.assertEqual(resp.headers['x-test-header-two-a'], 'value2')
def test_removed_outgoing_headers_match(self):
self.tempurl = tempurl.filter_factory({
@ -865,10 +865,10 @@ class TestTempURL(unittest.TestCase):
environ={'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
sig, expires)})
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 404)
self.assertEquals(resp.headers['x-test-header-one-a'], 'value1')
self.assertEqual(resp.status_int, 404)
self.assertEqual(resp.headers['x-test-header-one-a'], 'value1')
self.assertTrue('x-test-header-two-a' not in resp.headers)
self.assertEquals(resp.headers['x-test-header-two-b'], 'value3')
self.assertEqual(resp.headers['x-test-header-two-b'], 'value3')
def test_allow_trumps_outgoing_header_conflict(self):
self.tempurl = tempurl.filter_factory({
@ -888,7 +888,7 @@ class TestTempURL(unittest.TestCase):
self.tempurl.app = FakeApp(iter([('200 Ok', {
'X-Conflict-Header': 'value'}, '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('x-conflict-header' in resp.headers)
self.assertEqual(resp.headers['x-conflict-header'], 'value')
@ -910,96 +910,96 @@ class TestTempURL(unittest.TestCase):
self.tempurl.app = FakeApp(iter([('200 Ok', {
'X-Conflict-Header-Test': 'value'}, '123')]))
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 200)
self.assertEqual(resp.status_int, 200)
self.assertTrue('x-conflict-header-test' in resp.headers)
self.assertEqual(resp.headers['x-conflict-header-test'], 'value')
def test_get_account_and_container(self):
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'HEAD', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'PUT', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'POST', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'DELETE', 'PATH_INFO': '/v1/a/c/o'}), ('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'UNKNOWN', 'PATH_INFO': '/v1/a/c/o'}),
(None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/'}), (None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c//////'}),
(None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c///o///'}),
('a', 'c'))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c'}), (None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a//o'}), (None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1//c/o'}), (None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '//a/c/o'}), (None, None))
self.assertEquals(self.tempurl._get_account_and_container({
self.assertEqual(self.tempurl._get_account_and_container({
'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v2/a/c/o'}), (None, None))
def test_get_temp_url_info(self):
s = 'f5d5051bddf5df7e27c628818738334f'
e = int(time() + 86400)
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
s, e)}),
(s, e, None, None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&'
'filename=bobisyouruncle' % (s, e)}),
(s, e, 'bobisyouruncle', None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info({}),
(None, None, None, None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_expires=%s' % e}),
(None, e, None, None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s' % s}),
(s, None, None, None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=bad' % (
s)}),
(s, 0, None, None))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&'
'inline=' % (s, e)}),
(s, e, None, True))
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s&'
'filename=bobisyouruncle&inline=' % (s, e)}),
(s, e, 'bobisyouruncle', True))
e = int(time() - 1)
self.assertEquals(
self.assertEqual(
self.tempurl._get_temp_url_info(
{'QUERY_STRING': 'temp_url_sig=%s&temp_url_expires=%s' % (
s, e)}),
(s, 0, None, None))
def test_get_hmacs(self):
self.assertEquals(
self.assertEqual(
self.tempurl._get_hmacs(
{'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/a/c/o'},
1, [('abc', 'account')]),
[('026d7f7cc25256450423c7ad03fc9f5ffc1dab6d', 'account')])
self.assertEquals(
self.assertEqual(
self.tempurl._get_hmacs(
{'REQUEST_METHOD': 'HEAD', 'PATH_INFO': '/v1/a/c/o'},
1, [('abc', 'account')], request_method='GET'),
@ -1013,7 +1013,7 @@ class TestTempURL(unittest.TestCase):
self.assertTrue('Temp URL invalid' in ''.join(
self.tempurl._invalid({'REQUEST_METHOD': 'GET'},
_start_response)))
self.assertEquals('', ''.join(
self.assertEqual('', ''.join(
self.tempurl._invalid({'REQUEST_METHOD': 'HEAD'},
_start_response)))
@ -1022,7 +1022,7 @@ class TestTempURL(unittest.TestCase):
environ = {}
resp = self._make_request('/v1/a/c/o', environ=environ).get_response(
self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' not in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)
self.assertTrue('swift.auth_scheme' not in environ)
@ -1034,7 +1034,7 @@ class TestTempURL(unittest.TestCase):
req = self._make_request('/v1/a/c/o', keys=['abc'],
environ=environ)
resp = req.get_response(self.tempurl)
self.assertEquals(resp.status_int, 401)
self.assertEqual(resp.status_int, 401)
self.assertTrue('Temp URL invalid' in resp.body)
self.assertTrue('Www-Authenticate' in resp.headers)

View File

@ -88,13 +88,13 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'X-Versions-Location': 'ver_cont'},
environ={'REQUEST_METHOD': 'PUT'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
# check for sysmeta header
calls = self.app.calls_with_headers
method, path, req_headers = calls[0]
self.assertEquals('PUT', method)
self.assertEquals('/v1/a/c', path)
self.assertEqual('PUT', method)
self.assertEqual('/v1/a/c', path)
self.assertTrue('x-container-sysmeta-versions-location' in req_headers)
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -109,7 +109,7 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'X-Versions-Location': 'ver_cont'},
environ={'REQUEST_METHOD': method})
status, headers, body = self.call_vw(req)
self.assertEquals(status, "412 Precondition Failed")
self.assertEqual(status, "412 Precondition Failed")
# GET/HEAD performs as normal
self.app.register('GET', '/v1/a/c', swob.HTTPOk, {}, 'passed')
@ -120,7 +120,7 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'X-Versions-Location': 'ver_cont'},
environ={'REQUEST_METHOD': method})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
def test_remove_versions_location(self):
self.app.register('POST', '/v1/a/c', swob.HTTPOk, {}, 'passed')
@ -128,13 +128,13 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'X-Remove-Versions-Location': 'x'},
environ={'REQUEST_METHOD': 'POST'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
# check for sysmeta header
calls = self.app.calls_with_headers
method, path, req_headers = calls[0]
self.assertEquals('POST', method)
self.assertEquals('/v1/a/c', path)
self.assertEqual('POST', method)
self.assertEqual('/v1/a/c', path)
self.assertTrue('x-container-sysmeta-versions-location' in req_headers)
self.assertTrue('x-versions-location' in req_headers)
self.assertEqual(len(self.authorized), 1)
@ -151,14 +151,14 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'POST'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertTrue(('X-Versions-Location', 'ver_cont') in headers)
# check for sysmeta header
calls = self.app.calls_with_headers
method, path, req_headers = calls[0]
self.assertEquals('POST', method)
self.assertEquals('/v1/a/c', path)
self.assertEqual('POST', method)
self.assertEqual('/v1/a/c', path)
self.assertTrue('x-container-sysmeta-versions-location' in req_headers)
self.assertTrue('x-remove-versions-location' not in req_headers)
self.assertEqual(len(self.authorized), 1)
@ -172,7 +172,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'/v1/a/c',
environ={'REQUEST_METHOD': 'GET'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertTrue(('X-Versions-Location', 'ver_cont') in headers)
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -183,7 +183,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'/v1/a/c/o',
environ={'REQUEST_METHOD': 'GET'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -192,7 +192,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'/v1/a/c/o',
environ={'REQUEST_METHOD': 'HEAD'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -206,7 +206,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -222,7 +222,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -238,15 +238,15 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
# check for 'X-Backend-Storage-Policy-Index' in HEAD request
calls = self.app.calls_with_headers
method, path, req_headers = calls[0]
self.assertEquals('HEAD', method)
self.assertEquals('/v1/a/c/o', path)
self.assertEqual('HEAD', method)
self.assertEqual('/v1/a/c/o', path)
self.assertTrue('X-Backend-Storage-Policy-Index' in req_headers)
self.assertEquals('2',
self.assertEqual('2',
req_headers.get('X-Backend-Storage-Policy-Index'))
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -265,7 +265,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '201 Created')
self.assertEqual(status, '201 Created')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
called_method = [method for (method, path, hdrs) in self.app._calls]
@ -282,7 +282,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'/v1/a/c/o',
environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '204 No Content')
self.assertEqual(status, '204 No Content')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
called_method = \
@ -301,13 +301,13 @@ class VersionedWritesTestCase(unittest.TestCase):
'/v1/a/c/o',
environ={'REQUEST_METHOD': 'COPY', 'swift.cache': cache})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '201 Created')
self.assertEqual(status, '201 Created')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
called_method = \
[method for (method, path, rheaders) in self.app._calls]
self.assertTrue('COPY' in called_method)
self.assertEquals(called_method.count('COPY'), 1)
self.assertEqual(called_method.count('COPY'), 1)
def test_new_version_success(self):
self.app.register(
@ -323,7 +323,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -345,15 +345,15 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'PUT', 'swift.cache': cache,
'CONTENT_LENGTH': '100'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
# check that sysmeta header was used
calls = self.app.calls_with_headers
method, path, req_headers = calls[1]
self.assertEquals('COPY', method)
self.assertEquals('/v1/a/c/o', path)
self.assertEqual('COPY', method)
self.assertEqual('/v1/a/c/o', path)
self.assertTrue(req_headers['Destination'].startswith('ver_cont/'))
def test_copy_first_version(self):
@ -368,7 +368,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'CONTENT_LENGTH': '100'},
headers={'Destination': 'tgt_cont/tgt_obj'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -387,7 +387,7 @@ class VersionedWritesTestCase(unittest.TestCase):
'CONTENT_LENGTH': '100'},
headers={'Destination': 'tgt_cont/tgt_obj'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -407,7 +407,7 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'Destination': 'tgt_cont/tgt_obj',
'Destination-Account': 'tgt_a'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -420,7 +420,7 @@ class VersionedWritesTestCase(unittest.TestCase):
headers={'Destination': 'tgt_cont/tgt_obj',
'Destination-Account': '/im/on/a/boat'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '412 Precondition Failed')
self.assertEqual(status, '412 Precondition Failed')
def test_delete_first_object_success(self):
self.app.register(
@ -435,7 +435,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache,
'CONTENT_LENGTH': '0'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -473,14 +473,14 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache,
'CONTENT_LENGTH': '0'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
# check that X-If-Delete-At was removed from DELETE request
calls = self.app.calls_with_headers
method, path, req_headers = calls.pop()
self.assertEquals('DELETE', method)
self.assertEqual('DELETE', method)
self.assertTrue(path.startswith('/v1/a/ver_cont/001o/2'))
self.assertFalse('x-if-delete-at' in req_headers or
'X-If-Delete-At' in req_headers)
@ -521,7 +521,7 @@ class VersionedWritesTestCase(unittest.TestCase):
environ={'REQUEST_METHOD': 'DELETE', 'swift.cache': cache,
'CONTENT_LENGTH': '0'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '200 OK')
self.assertEqual(status, '200 OK')
self.assertEqual(len(self.authorized), 1)
self.assertRequestEqual(req, self.authorized[0])
@ -561,6 +561,6 @@ class VersionedWritesTestCase(unittest.TestCase):
'swift.authorize': fake_authorize,
'CONTENT_LENGTH': '0'})
status, headers, body = self.call_vw(req)
self.assertEquals(status, '403 Forbidden')
self.assertEqual(status, '403 Forbidden')
self.assertEqual(len(authorize_call), 1)
self.assertRequestEqual(req, authorize_call[0])

View File

@ -220,7 +220,7 @@ class Test_profile_log(unittest.TestCase):
shutil.rmtree(self.dir2, ignore_errors=True)
def test_get_all_pids(self):
self.assertEquals(self.profile_log1.get_all_pids(),
self.assertEqual(self.profile_log1.get_all_pids(),
sorted(self.pids1, reverse=True))
for pid in self.profile_log2.get_all_pids():
self.assertTrue(pid.split('-')[0] in self.pids2)
@ -247,18 +247,18 @@ class Test_profile_log(unittest.TestCase):
def test_get_logfiles(self):
log_files = self.profile_log1.get_logfiles('all')
self.assertEqual(len(log_files), 3)
self.assertEquals(len(log_files), len(self.pids1))
self.assertEqual(len(log_files), len(self.pids1))
log_files = self.profile_log1.get_logfiles('current')
self.assertEqual(len(log_files), 1)
self.assertEquals(log_files, [self.log_filename_prefix1
self.assertEqual(log_files, [self.log_filename_prefix1
+ str(os.getpid())])
log_files = self.profile_log1.get_logfiles(self.pids1[0])
self.assertEqual(len(log_files), 1)
self.assertEquals(log_files, [self.log_filename_prefix1
self.assertEqual(log_files, [self.log_filename_prefix1
+ self.pids1[0]])
log_files = self.profile_log2.get_logfiles('all')
self.assertEqual(len(log_files), 3)
self.assertEquals(len(log_files), len(self.pids2))
self.assertEqual(len(log_files), len(self.pids2))
log_files = self.profile_log2.get_logfiles('current')
self.assertEqual(len(log_files), 1)
self.assertTrue(log_files[0].find(self.log_filename_prefix2 +

View File

@ -62,13 +62,13 @@ class TestRingBuilder(unittest.TestCase):
def test_init(self):
rb = ring.RingBuilder(8, 3, 1)
self.assertEquals(rb.part_power, 8)
self.assertEquals(rb.replicas, 3)
self.assertEquals(rb.min_part_hours, 1)
self.assertEquals(rb.parts, 2 ** 8)
self.assertEquals(rb.devs, [])
self.assertEquals(rb.devs_changed, False)
self.assertEquals(rb.version, 0)
self.assertEqual(rb.part_power, 8)
self.assertEqual(rb.replicas, 3)
self.assertEqual(rb.min_part_hours, 1)
self.assertEqual(rb.parts, 2 ** 8)
self.assertEqual(rb.devs, [])
self.assertEqual(rb.devs_changed, False)
self.assertEqual(rb.version, 0)
def test_overlarge_part_powers(self):
ring.RingBuilder(32, 3, 1) # passes by not crashing
@ -166,7 +166,7 @@ class TestRingBuilder(unittest.TestCase):
self.assertFalse(rb0.get_ring() is r0)
self.assertNotEquals(r0.to_dict(), r1.to_dict())
self.assertEquals(r1.to_dict(), r2.to_dict())
self.assertEqual(r1.to_dict(), r2.to_dict())
def test_rebalance_part_on_deleted_other_part_on_drained(self):
rb = ring.RingBuilder(8, 3, 1)
@ -216,12 +216,12 @@ class TestRingBuilder(unittest.TestCase):
# test add new dev with no id
dev_id = rb.add_dev({'zone': 0, 'region': 1, 'weight': 1,
'ip': '127.0.0.1', 'port': 6000})
self.assertEquals(rb.devs[0]['id'], 0)
self.assertEqual(rb.devs[0]['id'], 0)
self.assertEqual(dev_id, 0)
# test add another dev with no id
dev_id = rb.add_dev({'zone': 3, 'region': 2, 'weight': 1,
'ip': '127.0.0.1', 'port': 6000})
self.assertEquals(rb.devs[1]['id'], 1)
self.assertEqual(rb.devs[1]['id'], 1)
self.assertEqual(dev_id, 1)
def test_set_dev_weight(self):
@ -240,7 +240,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 128, 1: 128, 2: 256, 3: 256})
self.assertEqual(counts, {0: 128, 1: 128, 2: 256, 3: 256})
rb.set_dev_weight(0, 0.75)
rb.set_dev_weight(1, 0.25)
rb.pretend_min_part_hours_passed()
@ -250,7 +250,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 192, 1: 64, 2: 256, 3: 256})
self.assertEqual(counts, {0: 192, 1: 64, 2: 256, 3: 256})
def test_remove_dev(self):
rb = ring.RingBuilder(8, 3, 1)
@ -268,7 +268,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 192, 1: 192, 2: 192, 3: 192})
self.assertEqual(counts, {0: 192, 1: 192, 2: 192, 3: 192})
rb.remove_dev(1)
rb.pretend_min_part_hours_passed()
rb.rebalance()
@ -277,7 +277,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 256, 2: 256, 3: 256})
self.assertEqual(counts, {0: 256, 2: 256, 3: 256})
def test_remove_a_lot(self):
rb = ring.RingBuilder(3, 3, 1)
@ -515,7 +515,7 @@ class TestRingBuilder(unittest.TestCase):
counts['zone'][dev['zone']] += 1
counts['dev_id'][dev['id']] += 1
self.assertEquals(8, sum(counts['zone'].values()))
self.assertEqual(8, sum(counts['zone'].values()))
for zone, replica_count in counts['zone'].items():
if replica_count not in (2, 3):
raise AssertionError(
@ -572,7 +572,7 @@ class TestRingBuilder(unittest.TestCase):
counts['zone'][dev['zone']] += 1
counts['dev_id'][dev['id']] += 1
self.assertEquals({0: 2, 1: 2, 2: 2}, dict(counts['zone']))
self.assertEqual({0: 2, 1: 2, 2: 2}, dict(counts['zone']))
# each part is assigned once to six unique devices
self.assertEqual((counts['dev_id'].values()), [1] * 6)
self.assertEqual(len(set(counts['dev_id'].keys())), 6)
@ -686,7 +686,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 256, 1: 256, 2: 256})
self.assertEqual(counts, {0: 256, 1: 256, 2: 256})
rb.add_dev({'id': 3, 'region': 0, 'zone': 3, 'weight': 1,
'ip': '127.0.0.1', 'port': 10003, 'device': 'sda1'})
rb.pretend_min_part_hours_passed()
@ -696,7 +696,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 192, 1: 192, 2: 192, 3: 192})
self.assertEqual(counts, {0: 192, 1: 192, 2: 192, 3: 192})
rb.set_dev_weight(3, 100)
rb.rebalance()
r = rb.get_ring()
@ -704,7 +704,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts[3], 256)
self.assertEqual(counts[3], 256)
def test_add_rebalance_add_rebalance_delete_rebalance(self):
# Test for https://bugs.launchpad.net/swift/+bug/845952
@ -822,7 +822,7 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance(seed=2)
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region,
self.assertEqual(population_by_region,
{0: 192, 1: 192, 2: 192, 3: 192})
def test_region_fullness_with_unbalanceable_ring(self):
@ -839,7 +839,7 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance(seed=2)
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region, {0: 512, 1: 256})
self.assertEqual(population_by_region, {0: 512, 1: 256})
def test_adding_region_slowly_with_unbalanceable_ring(self):
rb = ring.RingBuilder(8, 3, 1)
@ -873,7 +873,7 @@ class TestRingBuilder(unittest.TestCase):
# in it, so only 86 assignments occur in r1 (that's ~1/5 of the total,
# since r1 has 1/5 of the weight).
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region, {0: 682, 1: 86})
self.assertEqual(population_by_region, {0: 682, 1: 86})
# only 86 parts *should* move (to the new region) but randomly some
# parts will flop around devices in the original region too
@ -885,7 +885,7 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance(seed=2)
rb.validate()
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region, {0: 682, 1: 86})
self.assertEqual(population_by_region, {0: 682, 1: 86})
# after you add more weight, more partition assignments move
rb.set_dev_weight(2, 0.5)
@ -894,7 +894,7 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance(seed=2)
rb.validate()
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region, {0: 614, 1: 154})
self.assertEqual(population_by_region, {0: 614, 1: 154})
rb.set_dev_weight(2, 1.0)
rb.set_dev_weight(3, 1.0)
@ -902,7 +902,7 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance(seed=2)
rb.validate()
population_by_region = self._get_population_by_region(rb)
self.assertEquals(population_by_region, {0: 512, 1: 256})
self.assertEqual(population_by_region, {0: 512, 1: 256})
def test_avoid_tier_change_new_region(self):
rb = ring.RingBuilder(8, 3, 1)
@ -1088,7 +1088,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 96, 1: 96,
self.assertEqual(counts, {0: 96, 1: 96,
2: 32, 3: 32,
4: 96, 5: 96,
6: 32, 7: 32,
@ -1103,7 +1103,7 @@ class TestRingBuilder(unittest.TestCase):
for part2dev_id in r._replica2part2dev_id:
for dev_id in part2dev_id:
counts[dev_id] = counts.get(dev_id, 0) + 1
self.assertEquals(counts, {0: 192, 1: 192,
self.assertEqual(counts, {0: 192, 1: 192,
2: 64, 3: 64,
4: 192, 5: 192,
6: 64, 7: 64,
@ -1459,9 +1459,9 @@ class TestRingBuilder(unittest.TestCase):
fake_pickle = mock.Mock(return_value=rb)
pickle.load = fake_pickle
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
self.assertEquals(fake_pickle.call_count, 1)
self.assertEqual(fake_pickle.call_count, 1)
fake_open.assert_has_calls([mock.call('fake.builder', 'rb')])
self.assertEquals(builder, rb)
self.assertEqual(builder, rb)
fake_pickle.reset_mock()
# test old style builder
@ -1469,7 +1469,7 @@ class TestRingBuilder(unittest.TestCase):
pickle.load = fake_pickle
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
fake_open.assert_has_calls([mock.call('fake.builder', 'rb')])
self.assertEquals(builder.devs, rb.devs)
self.assertEqual(builder.devs, rb.devs)
fake_pickle.reset_mock()
# test old devs but no meta
@ -1480,7 +1480,7 @@ class TestRingBuilder(unittest.TestCase):
pickle.load = fake_pickle
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
fake_open.assert_has_calls([mock.call('fake.builder', 'rb')])
self.assertEquals(builder.devs, rb.devs)
self.assertEqual(builder.devs, rb.devs)
# test an empty builder
fake_pickle.side_effect = EOFError
@ -1549,8 +1549,8 @@ class TestRingBuilder(unittest.TestCase):
rb.save(builder_file)
loaded_rb = ring.RingBuilder.load(builder_file)
self.maxDiff = None
self.assertEquals(loaded_rb.to_dict(), rb.to_dict())
self.assertEquals(loaded_rb.overload, 3.14159)
self.assertEqual(loaded_rb.to_dict(), rb.to_dict())
self.assertEqual(loaded_rb.overload, 3.14159)
@mock.patch('six.moves.builtins.open', autospec=True)
@mock.patch('swift.common.ring.builder.pickle.dump', autospec=True)
@ -1607,32 +1607,32 @@ class TestRingBuilder(unittest.TestCase):
rb.add_dev(d)
rb.rebalance()
res = rb.search_devs({'region': 0})
self.assertEquals(res, [devs[0], devs[1]])
self.assertEqual(res, [devs[0], devs[1]])
res = rb.search_devs({'region': 1})
self.assertEquals(res, [devs[2], devs[3]])
self.assertEqual(res, [devs[2], devs[3]])
res = rb.search_devs({'region': 1, 'zone': 2})
self.assertEquals(res, [devs[2]])
self.assertEqual(res, [devs[2]])
res = rb.search_devs({'id': 1})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'zone': 1})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'ip': '127.0.0.1'})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'ip': '127.0.0.1', 'port': 10001})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'port': 10001})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'replication_ip': '127.0.0.10'})
self.assertEquals(res, [devs[4]])
self.assertEqual(res, [devs[4]])
res = rb.search_devs({'replication_ip': '127.0.0.10',
'replication_port': 20000})
self.assertEquals(res, [devs[4]])
self.assertEqual(res, [devs[4]])
res = rb.search_devs({'replication_port': 20000})
self.assertEquals(res, [devs[4]])
self.assertEqual(res, [devs[4]])
res = rb.search_devs({'device': 'sdb1'})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
res = rb.search_devs({'meta': 'meta1'})
self.assertEquals(res, [devs[1]])
self.assertEqual(res, [devs[1]])
def test_validate(self):
rb = ring.RingBuilder(8, 3, 1)
@ -1674,24 +1674,24 @@ class TestRingBuilder(unittest.TestCase):
rb.rebalance()
counts = self._partition_counts(rb, key='zone')
self.assertEquals(counts, {0: 128, 1: 128, 2: 256, 3: 256})
self.assertEqual(counts, {0: 128, 1: 128, 2: 256, 3: 256})
dev_usage, worst = rb.validate()
self.assertTrue(dev_usage is None)
self.assertTrue(worst is None)
dev_usage, worst = rb.validate(stats=True)
self.assertEquals(list(dev_usage), [32, 32, 64, 64,
self.assertEqual(list(dev_usage), [32, 32, 64, 64,
32, 32, 32, # added zone0
32, 32, 32, # added zone1
64, 64, 64, # added zone2
64, 64, 64, # added zone3
])
self.assertEquals(int(worst), 0)
self.assertEqual(int(worst), 0)
rb.set_dev_weight(2, 0)
rb.rebalance()
self.assertEquals(rb.validate(stats=True)[1], MAX_BALANCE)
self.assertEqual(rb.validate(stats=True)[1], MAX_BALANCE)
# Test not all partitions doubly accounted for
rb.devs[1]['parts'] -= 1

View File

@ -54,10 +54,10 @@ class TestRingData(unittest.TestCase):
rmtree(self.testdir, ignore_errors=1)
def assert_ring_data_equal(self, rd_expected, rd_got):
self.assertEquals(rd_expected._replica2part2dev_id,
self.assertEqual(rd_expected._replica2part2dev_id,
rd_got._replica2part2dev_id)
self.assertEquals(rd_expected.devs, rd_got.devs)
self.assertEquals(rd_expected._part_shift, rd_got._part_shift)
self.assertEqual(rd_expected.devs, rd_got.devs)
self.assertEqual(rd_expected._part_shift, rd_got._part_shift)
def test_attrs(self):
r2p2d = [[0, 1, 0, 1], [0, 1, 0, 1]]
@ -65,9 +65,9 @@ class TestRingData(unittest.TestCase):
{'id': 1, 'zone': 1, 'region': 1, 'ip': '10.1.1.1', 'port': 7000}]
s = 30
rd = ring.RingData(r2p2d, d, s)
self.assertEquals(rd._replica2part2dev_id, r2p2d)
self.assertEquals(rd.devs, d)
self.assertEquals(rd._part_shift, s)
self.assertEqual(rd._replica2part2dev_id, r2p2d)
self.assertEqual(rd.devs, d)
self.assertEqual(rd._part_shift, s)
def test_can_load_pickled_ring_data(self):
rd = ring.RingData(
@ -180,12 +180,12 @@ class TestRing(TestRingBase):
rmtree(self.testdir, ignore_errors=1)
def test_creation(self):
self.assertEquals(self.ring._replica2part2dev_id,
self.assertEqual(self.ring._replica2part2dev_id,
self.intended_replica2part2dev_id)
self.assertEquals(self.ring._part_shift, self.intended_part_shift)
self.assertEquals(self.ring.devs, self.intended_devs)
self.assertEquals(self.ring.reload_time, self.intended_reload_time)
self.assertEquals(self.ring.serialized_path, self.testgz)
self.assertEqual(self.ring._part_shift, self.intended_part_shift)
self.assertEqual(self.ring.devs, self.intended_devs)
self.assertEqual(self.ring.reload_time, self.intended_reload_time)
self.assertEqual(self.ring.serialized_path, self.testgz)
# test invalid endcap
_orig_hash_path_suffix = utils.HASH_PATH_SUFFIX
_orig_hash_path_prefix = utils.HASH_PATH_PREFIX
@ -201,16 +201,16 @@ class TestRing(TestRingBase):
utils.SWIFT_CONF_FILE = _orig_swift_conf_file
def test_has_changed(self):
self.assertEquals(self.ring.has_changed(), False)
self.assertEqual(self.ring.has_changed(), False)
os.utime(self.testgz, (time() + 60, time() + 60))
self.assertEquals(self.ring.has_changed(), True)
self.assertEqual(self.ring.has_changed(), True)
def test_reload(self):
os.utime(self.testgz, (time() - 300, time() - 300))
self.ring = ring.Ring(self.testdir, reload_time=0.001,
ring_name='whatever')
orig_mtime = self.ring._mtime
self.assertEquals(len(self.ring.devs), 5)
self.assertEqual(len(self.ring.devs), 5)
self.intended_devs.append(
{'id': 3, 'region': 0, 'zone': 3, 'weight': 1.0,
'ip': '10.1.1.1', 'port': 9876})
@ -219,14 +219,14 @@ class TestRing(TestRingBase):
self.intended_devs, self.intended_part_shift).save(self.testgz)
sleep(0.1)
self.ring.get_nodes('a')
self.assertEquals(len(self.ring.devs), 6)
self.assertEqual(len(self.ring.devs), 6)
self.assertNotEquals(self.ring._mtime, orig_mtime)
os.utime(self.testgz, (time() - 300, time() - 300))
self.ring = ring.Ring(self.testdir, reload_time=0.001,
ring_name='whatever')
orig_mtime = self.ring._mtime
self.assertEquals(len(self.ring.devs), 6)
self.assertEqual(len(self.ring.devs), 6)
self.intended_devs.append(
{'id': 5, 'region': 0, 'zone': 4, 'weight': 1.0,
'ip': '10.5.5.5', 'port': 9876})
@ -235,7 +235,7 @@ class TestRing(TestRingBase):
self.intended_devs, self.intended_part_shift).save(self.testgz)
sleep(0.1)
self.ring.get_part_nodes(0)
self.assertEquals(len(self.ring.devs), 7)
self.assertEqual(len(self.ring.devs), 7)
self.assertNotEquals(self.ring._mtime, orig_mtime)
os.utime(self.testgz, (time() - 300, time() - 300))
@ -243,7 +243,7 @@ class TestRing(TestRingBase):
ring_name='whatever')
orig_mtime = self.ring._mtime
part, nodes = self.ring.get_nodes('a')
self.assertEquals(len(self.ring.devs), 7)
self.assertEqual(len(self.ring.devs), 7)
self.intended_devs.append(
{'id': 6, 'region': 0, 'zone': 5, 'weight': 1.0,
'ip': '10.6.6.6', 'port': 6000})
@ -252,14 +252,14 @@ class TestRing(TestRingBase):
self.intended_devs, self.intended_part_shift).save(self.testgz)
sleep(0.1)
next(self.ring.get_more_nodes(part))
self.assertEquals(len(self.ring.devs), 8)
self.assertEqual(len(self.ring.devs), 8)
self.assertNotEquals(self.ring._mtime, orig_mtime)
os.utime(self.testgz, (time() - 300, time() - 300))
self.ring = ring.Ring(self.testdir, reload_time=0.001,
ring_name='whatever')
orig_mtime = self.ring._mtime
self.assertEquals(len(self.ring.devs), 8)
self.assertEqual(len(self.ring.devs), 8)
self.intended_devs.append(
{'id': 5, 'region': 0, 'zone': 4, 'weight': 1.0,
'ip': '10.5.5.5', 'port': 6000})
@ -267,7 +267,7 @@ class TestRing(TestRingBase):
self.intended_replica2part2dev_id,
self.intended_devs, self.intended_part_shift).save(self.testgz)
sleep(0.1)
self.assertEquals(len(self.ring.devs), 9)
self.assertEqual(len(self.ring.devs), 9)
self.assertNotEquals(self.ring._mtime, orig_mtime)
def test_reload_without_replication(self):
@ -309,7 +309,7 @@ class TestRing(TestRingBase):
self.testdir,
reload_time=self.intended_reload_time,
ring_name='without_replication')
self.assertEquals(self.ring.devs, intended_devs)
self.assertEqual(self.ring.devs, intended_devs)
def test_reload_old_style_pickled_ring(self):
devs = [{'id': 0, 'zone': 0,
@ -361,91 +361,91 @@ class TestRing(TestRingBase):
self.testdir,
reload_time=self.intended_reload_time,
ring_name='without_replication_or_region')
self.assertEquals(self.ring.devs, intended_devs)
self.assertEqual(self.ring.devs, intended_devs)
def test_get_part(self):
part1 = self.ring.get_part('a')
nodes1 = self.ring.get_part_nodes(part1)
part2, nodes2 = self.ring.get_nodes('a')
self.assertEquals(part1, part2)
self.assertEquals(nodes1, nodes2)
self.assertEqual(part1, part2)
self.assertEqual(nodes1, nodes2)
def test_get_part_nodes(self):
part, nodes = self.ring.get_nodes('a')
self.assertEquals(nodes, self.ring.get_part_nodes(part))
self.assertEqual(nodes, self.ring.get_part_nodes(part))
def test_get_nodes(self):
# Yes, these tests are deliberately very fragile. We want to make sure
# that if someones changes the results the ring produces, they know it.
self.assertRaises(TypeError, self.ring.get_nodes)
part, nodes = self.ring.get_nodes('a')
self.assertEquals(part, 0)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 0)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a1')
self.assertEquals(part, 0)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 0)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a4')
self.assertEquals(part, 1)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 1)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[1],
self.intended_devs[4]])])
part, nodes = self.ring.get_nodes('aa')
self.assertEquals(part, 1)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 1)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[1],
self.intended_devs[4]])])
part, nodes = self.ring.get_nodes('a', 'c1')
self.assertEquals(part, 0)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 0)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a', 'c0')
self.assertEquals(part, 3)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 3)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[1],
self.intended_devs[4]])])
part, nodes = self.ring.get_nodes('a', 'c3')
self.assertEquals(part, 2)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 2)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a', 'c2')
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a', 'c', 'o1')
self.assertEquals(part, 1)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 1)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[1],
self.intended_devs[4]])])
part, nodes = self.ring.get_nodes('a', 'c', 'o5')
self.assertEquals(part, 0)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 0)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a', 'c', 'o0')
self.assertEquals(part, 0)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 0)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
part, nodes = self.ring.get_nodes('a', 'c', 'o2')
self.assertEquals(part, 2)
self.assertEquals(nodes, [dict(node, index=i) for i, node in
self.assertEqual(part, 2)
self.assertEqual(nodes, [dict(node, index=i) for i, node in
enumerate([self.intended_devs[0],
self.intended_devs[3]])])
@ -506,23 +506,23 @@ class TestRing(TestRingBase):
r = ring.Ring(self.testdir, ring_name='whatever')
part, devs = r.get_nodes('a', 'c', 'o')
primary_zones = set([d['zone'] for d in devs])
self.assertEquals(part, exp_part)
self.assertEquals([d['id'] for d in devs], exp_devs)
self.assertEquals(primary_zones, exp_zones)
self.assertEqual(part, exp_part)
self.assertEqual([d['id'] for d in devs], exp_devs)
self.assertEqual(primary_zones, exp_zones)
devs = list(r.get_more_nodes(part))
self.assertEquals([d['id'] for d in devs], exp_handoffs)
self.assertEqual([d['id'] for d in devs], exp_handoffs)
# The first 6 replicas plus the 3 primary nodes should cover all 9
# zones in this test
seen_zones = set(primary_zones)
seen_zones.update([d['zone'] for d in devs[:6]])
self.assertEquals(seen_zones, set(range(1, 10)))
self.assertEqual(seen_zones, set(range(1, 10)))
# The first handoff nodes for each partition in the ring
devs = []
for part in range(r.partition_count):
devs.append(next(r.get_more_nodes(part))['id'])
self.assertEquals(devs, exp_first_handoffs)
self.assertEqual(devs, exp_first_handoffs)
# Add a new device we can handoff to.
zone = 5
@ -538,14 +538,14 @@ class TestRing(TestRingBase):
# changed at all.
part, devs = r.get_nodes('a', 'c', 'o')
primary_zones = set([d['zone'] for d in devs])
self.assertEquals(part, exp_part)
self.assertEquals([d['id'] for d in devs], exp_devs)
self.assertEquals(primary_zones, exp_zones)
self.assertEqual(part, exp_part)
self.assertEqual([d['id'] for d in devs], exp_devs)
self.assertEqual(primary_zones, exp_zones)
devs = list(r.get_more_nodes(part))
dev_ids = [d['id'] for d in devs]
self.assertEquals(len(dev_ids), len(exp_handoffs))
self.assertEqual(len(dev_ids), len(exp_handoffs))
for index, dev in enumerate(dev_ids):
self.assertEquals(
self.assertEqual(
dev, exp_handoffs[index],
'handoff differs at position %d\n%s\n%s' % (
index, dev_ids[index:], exp_handoffs[index:]))
@ -553,13 +553,13 @@ class TestRing(TestRingBase):
# The handoffs still cover all the non-primary zones first
seen_zones = set(primary_zones)
seen_zones.update([d['zone'] for d in devs[:6]])
self.assertEquals(seen_zones, set(range(1, 10)))
self.assertEqual(seen_zones, set(range(1, 10)))
devs = []
for part in range(r.partition_count):
devs.append(next(r.get_more_nodes(part))['id'])
for part in range(r.partition_count):
self.assertEquals(
self.assertEqual(
devs[part], exp_first_handoffs[part],
'handoff for partitition %d is now device id %d' % (
part, devs[part]))
@ -588,27 +588,27 @@ class TestRing(TestRingBase):
# Test
part, devs = r.get_nodes('a', 'c', 'o')
primary_zones = set([d['zone'] for d in devs])
self.assertEquals(part, exp_part)
self.assertEquals([d['id'] for d in devs], exp_devs)
self.assertEquals(primary_zones, exp_zones)
self.assertEqual(part, exp_part)
self.assertEqual([d['id'] for d in devs], exp_devs)
self.assertEqual(primary_zones, exp_zones)
devs = list(r.get_more_nodes(part))
dev_ids = [d['id'] for d in devs]
self.assertEquals(len(dev_ids), len(exp_handoffs))
self.assertEqual(len(dev_ids), len(exp_handoffs))
for index, dev in enumerate(dev_ids):
self.assertEquals(
self.assertEqual(
dev, exp_handoffs[index],
'handoff differs at position %d\n%s\n%s' % (
index, dev_ids[index:], exp_handoffs[index:]))
seen_zones = set(primary_zones)
seen_zones.update([d['zone'] for d in devs[:6]])
self.assertEquals(seen_zones, set(range(1, 10)))
self.assertEqual(seen_zones, set(range(1, 10)))
devs = []
for part in range(r.partition_count):
devs.append(next(r.get_more_nodes(part))['id'])
for part in range(r.partition_count):
self.assertEquals(
self.assertEqual(
devs[part], exp_first_handoffs[part],
'handoff for partitition %d is now device id %d' % (
part, devs[part]))
@ -668,28 +668,28 @@ class TestRing(TestRingBase):
# Test
part, devs = r.get_nodes('a', 'c', 'o')
primary_zones = set([d['zone'] for d in devs])
self.assertEquals(part, exp_part)
self.assertEquals([d['id'] for d in devs], exp_devs)
self.assertEquals(primary_zones, exp_zones)
self.assertEqual(part, exp_part)
self.assertEqual([d['id'] for d in devs], exp_devs)
self.assertEqual(primary_zones, exp_zones)
devs = list(r.get_more_nodes(part))
dev_ids = [d['id'] for d in devs]
self.assertEquals(len(dev_ids), len(exp_handoffs))
self.assertEqual(len(dev_ids), len(exp_handoffs))
for index, dev in enumerate(dev_ids):
self.assertEquals(
self.assertEqual(
dev, exp_handoffs[index],
'handoff differs at position %d\n%s\n%s' % (
index, dev_ids[index:], exp_handoffs[index:]))
seen_zones = set(primary_zones)
seen_zones.update([d['zone'] for d in devs[:6]])
self.assertEquals(seen_zones, set(range(1, 10)))
self.assertEqual(seen_zones, set(range(1, 10)))
devs = []
for part in range(r.partition_count):
devs.append(next(r.get_more_nodes(part))['id'])
for part in range(r.partition_count):
self.assertEquals(
self.assertEqual(
devs[part], exp_first_handoffs[part],
'handoff for partitition %d is now device id %d' % (
part, devs[part]))
@ -710,22 +710,22 @@ class TestRing(TestRingBase):
part2, devs2 = r.get_nodes('a', 'c', 'o2')
primary_zones2 = set([d['zone'] for d in devs2])
self.assertEquals(part2, exp_part2)
self.assertEquals([d['id'] for d in devs2], exp_devs2)
self.assertEquals(primary_zones2, exp_zones2)
self.assertEqual(part2, exp_part2)
self.assertEqual([d['id'] for d in devs2], exp_devs2)
self.assertEqual(primary_zones2, exp_zones2)
devs2 = list(r.get_more_nodes(part2))
dev_ids2 = [d['id'] for d in devs2]
self.assertEquals(len(dev_ids2), len(exp_handoffs2))
self.assertEqual(len(dev_ids2), len(exp_handoffs2))
for index, dev in enumerate(dev_ids2):
self.assertEquals(
self.assertEqual(
dev, exp_handoffs2[index],
'handoff differs at position %d\n%s\n%s' % (
index, dev_ids2[index:], exp_handoffs2[index:]))
seen_zones = set(primary_zones2)
seen_zones.update([d['zone'] for d in devs2[:6]])
self.assertEquals(seen_zones, set(range(1, 10)))
self.assertEqual(seen_zones, set(range(1, 10)))
# Test distribution across regions
rb.set_replicas(3)
@ -753,14 +753,14 @@ class TestRing(TestRingBase):
seen_regions = set(primary_regions)
seen_regions.update([d['region'] for d in more_devs[:2]])
self.assertEquals(seen_regions, set(range(0, 5)))
self.assertEqual(seen_regions, set(range(0, 5)))
# There are 13 zones now, so the first 13 nodes should all have
# distinct zones (that's r0z0, r0z1, ..., r0z8, r1z1, r2z1, r3z1, and
# r4z1).
seen_zones = set(primary_zones)
seen_zones.update([(d['region'], d['zone']) for d in more_devs[:10]])
self.assertEquals(13, len(seen_zones))
self.assertEqual(13, len(seen_zones))
# Here's a brittle canary-in-the-coalmine test to make sure the region
# handoff computation didn't change accidentally
@ -774,9 +774,9 @@ class TestRing(TestRingBase):
51, 70, 82, 67, 68, 8, 95, 91, 55, 59, 85]
dev_ids = [d['id'] for d in more_devs]
self.assertEquals(len(dev_ids), len(exp_handoffs))
self.assertEqual(len(dev_ids), len(exp_handoffs))
for index, dev_id in enumerate(dev_ids):
self.assertEquals(
self.assertEqual(
dev_id, exp_handoffs[index],
'handoff differs at position %d\n%s\n%s' % (
index, dev_ids[index:], exp_handoffs[index:]))

View File

@ -307,7 +307,7 @@ class TestUtils(unittest.TestCase):
}
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_search_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
argv = \
["--id", "1", "--region", "2", "--zone", "3",
@ -338,7 +338,7 @@ class TestUtils(unittest.TestCase):
}
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_search_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
argv = \
["--id", "1", "--region", "2", "--zone", "3",
@ -357,7 +357,7 @@ class TestUtils(unittest.TestCase):
"--change-meta", "some meta data for change"]
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_search_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
def test_parse_change_values_from_opts(self):
argv = \
@ -385,7 +385,7 @@ class TestUtils(unittest.TestCase):
}
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_change_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
argv = \
["--id", "1", "--region", "2", "--zone", "3",
@ -412,7 +412,7 @@ class TestUtils(unittest.TestCase):
}
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_change_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
argv = \
["--id", "1", "--region", "2", "--zone", "3",
@ -431,7 +431,7 @@ class TestUtils(unittest.TestCase):
"--change-meta", "some meta data for change"]
new_cmd_format, opts, args = validate_args(argv)
search_values = parse_change_values_from_opts(opts)
self.assertEquals(search_values, expected)
self.assertEqual(search_values, expected)
def test_validate_args(self):
argv = \
@ -560,20 +560,20 @@ class TestUtils(unittest.TestCase):
def test_parse_builder_ring_filename_args(self):
args = 'swift-ring-builder object.builder write_ring'
self.assertEquals((
self.assertEqual((
'object.builder', 'object.ring.gz'
), parse_builder_ring_filename_args(args.split()))
args = 'swift-ring-builder container.ring.gz write_builder'
self.assertEquals((
self.assertEqual((
'container.builder', 'container.ring.gz'
), parse_builder_ring_filename_args(args.split()))
# builder name arg should always fall through
args = 'swift-ring-builder test create'
self.assertEquals((
self.assertEqual((
'test', 'test.ring.gz'
), parse_builder_ring_filename_args(args.split()))
args = 'swift-ring-builder my.file.name create'
self.assertEquals((
self.assertEqual((
'my.file.name', 'my.file.name.ring.gz'
), parse_builder_ring_filename_args(args.split()))
@ -600,7 +600,7 @@ class TestUtils(unittest.TestCase):
}
opts, args = parse_args(argv)
device = build_dev_from_opts(opts)
self.assertEquals(device, expected)
self.assertEqual(device, expected)
argv = \
["--region", "2", "--zone", "3",
@ -640,7 +640,7 @@ class TestUtils(unittest.TestCase):
'weight': 100.0,
'zone': 1,
}
self.assertEquals(device, expected)
self.assertEqual(device, expected)
args = '-r 1 -z 1 -i test.com -p 6010 -d d1 -w 100'.split()
opts, _ = parse_args(args)
@ -656,7 +656,7 @@ class TestUtils(unittest.TestCase):
'weight': 100.0,
'zone': 1,
}
self.assertEquals(device, expected)
self.assertEqual(device, expected)
def test_dispersion_report(self):
rb = ring.RingBuilder(8, 3, 0)

View File

@ -60,7 +60,7 @@ class TestBaseStorageServer(unittest.TestCase):
try:
baseserver.server_type
except NotImplementedError as e:
self.assertEquals(str(e), msg)
self.assertEqual(str(e), msg)
def test_allowed_methods(self):
conf = {'devices': self.testdir, 'mount_check': 'false',
@ -68,34 +68,34 @@ class TestBaseStorageServer(unittest.TestCase):
# test what's available in the base class
allowed_methods_test = FakeOPTIONS(conf).allowed_methods
self.assertEquals(allowed_methods_test, ['OPTIONS'])
self.assertEqual(allowed_methods_test, ['OPTIONS'])
# test that a subclass can add allowed methods
allowed_methods_test = FakeANOTHER(conf).allowed_methods
allowed_methods_test.sort()
self.assertEquals(allowed_methods_test, ['ANOTHER', 'OPTIONS'])
self.assertEqual(allowed_methods_test, ['ANOTHER', 'OPTIONS'])
conf = {'devices': self.testdir, 'mount_check': 'false',
'replication_server': 'true'}
# test what's available in the base class
allowed_methods_test = FakeOPTIONS(conf).allowed_methods
self.assertEquals(allowed_methods_test, [])
self.assertEqual(allowed_methods_test, [])
# test that a subclass can add allowed methods
allowed_methods_test = FakeANOTHER(conf).allowed_methods
self.assertEquals(allowed_methods_test, [])
self.assertEqual(allowed_methods_test, [])
conf = {'devices': self.testdir, 'mount_check': 'false'}
# test what's available in the base class
allowed_methods_test = FakeOPTIONS(conf).allowed_methods
self.assertEquals(allowed_methods_test, ['OPTIONS'])
self.assertEqual(allowed_methods_test, ['OPTIONS'])
# test that a subclass can add allowed methods
allowed_methods_test = FakeANOTHER(conf).allowed_methods
allowed_methods_test.sort()
self.assertEquals(allowed_methods_test, ['ANOTHER', 'OPTIONS'])
self.assertEqual(allowed_methods_test, ['ANOTHER', 'OPTIONS'])
def test_OPTIONS_error(self):
msg = 'Storage nodes have not implemented the Server type.'
@ -109,7 +109,7 @@ class TestBaseStorageServer(unittest.TestCase):
try:
baseserver.OPTIONS(req)
except NotImplementedError as e:
self.assertEquals(str(e), msg)
self.assertEqual(str(e), msg)
def test_OPTIONS(self):
conf = {'devices': self.testdir, 'mount_check': 'false',
@ -117,6 +117,6 @@ class TestBaseStorageServer(unittest.TestCase):
req = Request.blank('/sda1/p/a/c/o', {'REQUEST_METHOD': 'OPTIONS'})
req.content_length = 0
resp = FakeOPTIONS(conf).OPTIONS(req)
self.assertEquals(resp.headers['Allow'], 'OPTIONS')
self.assertEquals(resp.headers['Server'],
self.assertEqual(resp.headers['Allow'], 'OPTIONS')
self.assertEqual(resp.headers['Server'],
'test-server/' + swift_version)

View File

@ -55,7 +55,7 @@ class TestBufferedHTTP(unittest.TestCase):
fp.write('HTTP/1.1 200 OK\r\nContent-Length: 8\r\n\r\n'
'RESPONSE')
fp.flush()
self.assertEquals(
self.assertEqual(
fp.readline(),
'PUT /dev/%s/path/..%%25/?omg&no=%%7f HTTP/1.1\r\n' %
expected_par)
@ -65,9 +65,9 @@ class TestBufferedHTTP(unittest.TestCase):
headers[line.split(':')[0].lower()] = \
line.split(':')[1].strip()
line = fp.readline()
self.assertEquals(headers['content-length'], '7')
self.assertEquals(headers['x-header'], 'value')
self.assertEquals(fp.readline(), 'REQUEST\r\n')
self.assertEqual(headers['content-length'], '7')
self.assertEqual(headers['x-header'], 'value')
self.assertEqual(fp.readline(), 'REQUEST\r\n')
except BaseException as err:
return err
return None
@ -87,9 +87,9 @@ class TestBufferedHTTP(unittest.TestCase):
resp = conn.getresponse()
body = resp.read()
conn.close()
self.assertEquals(resp.status, 200)
self.assertEquals(resp.reason, 'OK')
self.assertEquals(body, 'RESPONSE')
self.assertEqual(resp.status, 200)
self.assertEqual(resp.reason, 'OK')
self.assertEqual(body, 'RESPONSE')
finally:
err = event.wait()
if err:

View File

@ -39,12 +39,12 @@ class TestConstraints(unittest.TestCase):
def test_check_metadata_empty(self):
headers = {}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
def test_check_metadata_good(self):
headers = {'X-Object-Meta-Name': 'Value'}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
def test_check_metadata_empty_name(self):
@ -55,11 +55,11 @@ class TestConstraints(unittest.TestCase):
def test_check_metadata_name_length(self):
name = 'a' * constraints.MAX_META_NAME_LENGTH
headers = {'X-Object-Meta-%s' % name: 'v'}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
name = 'a' * (constraints.MAX_META_NAME_LENGTH + 1)
headers = {'X-Object-Meta-%s' % name: 'v'}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST)
self.assertIn(
('X-Object-Meta-%s' % name).lower(),
@ -69,11 +69,11 @@ class TestConstraints(unittest.TestCase):
def test_check_metadata_value_length(self):
value = 'a' * constraints.MAX_META_VALUE_LENGTH
headers = {'X-Object-Meta-Name': value}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
value = 'a' * (constraints.MAX_META_VALUE_LENGTH + 1)
headers = {'X-Object-Meta-Name': value}
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST)
self.assertIn(
'x-object-meta-name',
@ -90,10 +90,10 @@ class TestConstraints(unittest.TestCase):
headers = {}
for x in range(constraints.MAX_META_COUNT):
headers['X-Object-Meta-%d' % x] = 'v'
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
headers['X-Object-Meta-Too-Many'] = 'v'
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST)
def test_check_metadata_size(self):
@ -108,7 +108,7 @@ class TestConstraints(unittest.TestCase):
'v' * constraints.MAX_META_VALUE_LENGTH
size += chunk
x += 1
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object'), None)
# add two more headers in case adding just one falls exactly on the
# limit (eg one header adds 1024 and the limit is 2048)
@ -118,46 +118,46 @@ class TestConstraints(unittest.TestCase):
headers['X-Object-Meta-%04d%s' %
(x + 1, 'a' * (constraints.MAX_META_NAME_LENGTH - 4))] = \
'v' * constraints.MAX_META_VALUE_LENGTH
self.assertEquals(constraints.check_metadata(Request.blank(
self.assertEqual(constraints.check_metadata(Request.blank(
'/', headers=headers), 'object').status_int, HTTP_BAD_REQUEST)
def test_check_object_creation_content_length(self):
headers = {'Content-Length': str(constraints.MAX_FILE_SIZE),
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name'), None)
headers = {'Content-Length': str(constraints.MAX_FILE_SIZE + 1),
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(
self.assertEqual(constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name').status_int,
HTTP_REQUEST_ENTITY_TOO_LARGE)
headers = {'Transfer-Encoding': 'chunked',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name'), None)
headers = {'Transfer-Encoding': 'gzip',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name').status_int,
HTTP_BAD_REQUEST)
headers = {'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(
self.assertEqual(constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name').status_int,
HTTP_LENGTH_REQUIRED)
headers = {'Content-Length': 'abc',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name').status_int,
HTTP_BAD_REQUEST)
headers = {'Transfer-Encoding': 'gzip,chunked',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name').status_int,
HTTP_NOT_IMPLEMENTED)
@ -165,26 +165,26 @@ class TestConstraints(unittest.TestCase):
headers = {'Content-Length': '0',
'X-Copy-From': 'c/o2',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name'), None)
headers = {'Content-Length': '1',
'X-Copy-From': 'c/o2',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name').status_int,
HTTP_BAD_REQUEST)
headers = {'Transfer-Encoding': 'chunked',
'X-Copy-From': 'c/o2',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name'), None)
# a content-length header is always required
headers = {'X-Copy-From': 'c/o2',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name').status_int,
HTTP_LENGTH_REQUIRED)
@ -192,20 +192,20 @@ class TestConstraints(unittest.TestCase):
headers = {'Transfer-Encoding': 'chunked',
'Content-Type': 'text/plain'}
name = 'o' * constraints.MAX_OBJECT_NAME_LENGTH
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), name), None)
name = 'o' * (constraints.MAX_OBJECT_NAME_LENGTH + 1)
self.assertEquals(constraints.check_object_creation(
self.assertEqual(constraints.check_object_creation(
Request.blank('/', headers=headers), name).status_int,
HTTP_BAD_REQUEST)
def test_check_object_creation_content_type(self):
headers = {'Transfer-Encoding': 'chunked',
'Content-Type': 'text/plain'}
self.assertEquals(constraints.check_object_creation(Request.blank(
self.assertEqual(constraints.check_object_creation(Request.blank(
'/', headers=headers), 'object_name'), None)
headers = {'Transfer-Encoding': 'chunked'}
self.assertEquals(constraints.check_object_creation(
self.assertEqual(constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name').status_int,
HTTP_BAD_REQUEST)
@ -214,7 +214,7 @@ class TestConstraints(unittest.TestCase):
'Content-Type': '\xff\xff'}
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assertEqual(resp.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Content-Type' in resp.body)
def test_check_object_creation_bad_delete_headers(self):
@ -223,7 +223,7 @@ class TestConstraints(unittest.TestCase):
'X-Delete-After': 'abc'}
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assertEqual(resp.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Non-integer X-Delete-After' in resp.body)
t = str(int(time.time() - 60))
@ -232,7 +232,7 @@ class TestConstraints(unittest.TestCase):
'X-Delete-At': t}
resp = constraints.check_object_creation(
Request.blank('/', headers=headers), 'object_name')
self.assertEquals(resp.status_int, HTTP_BAD_REQUEST)
self.assertEqual(resp.status_int, HTTP_BAD_REQUEST)
self.assertTrue('X-Delete-At in past' in resp.body)
def test_check_delete_headers(self):
@ -249,7 +249,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Non-integer X-Delete-After' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -259,7 +259,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Non-integer X-Delete-After' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -269,7 +269,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('X-Delete-After in past' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -281,14 +281,14 @@ class TestConstraints(unittest.TestCase):
Request.blank('/', headers=headers))
self.assertTrue(isinstance(resp, Request))
self.assertTrue('x-delete-at' in resp.headers)
self.assertEquals(resp.headers.get('X-Delete-At'), t)
self.assertEqual(resp.headers.get('X-Delete-At'), t)
headers = {'X-Delete-At': 'abc'}
try:
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Non-integer X-Delete-At' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -299,7 +299,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('Non-integer X-Delete-At' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -310,7 +310,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('X-Delete-At in past' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -321,7 +321,7 @@ class TestConstraints(unittest.TestCase):
resp = constraints.check_delete_headers(
Request.blank('/', headers=headers))
except HTTPException as e:
self.assertEquals(e.status_int, HTTP_BAD_REQUEST)
self.assertEqual(e.status_int, HTTP_BAD_REQUEST)
self.assertTrue('X-Delete-At in past' in e.body)
else:
self.fail("Should have failed with HTTPBadRequest")
@ -435,7 +435,7 @@ class TestConstraints(unittest.TestCase):
'/v/a/c/o',
headers={'x-object-meta-hello':
'ab' * constraints.MAX_HEADER_SIZE})
self.assertEquals(constraints.check_metadata(req, 'object').status_int,
self.assertEqual(constraints.check_metadata(req, 'object').status_int,
HTTP_BAD_REQUEST)
self.assertIn('x-object-meta-hello', constraints.check_metadata(req,
'object').body.lower())
@ -544,7 +544,7 @@ class TestConstraintsConfig(unittest.TestCase):
# module level attrs (that aren't in OVERRIDE) should have the
# same value as the DEFAULT map
module_level_value = getattr(constraints, key.upper())
self.assertEquals(constraints.DEFAULT_CONSTRAINTS[key],
self.assertEqual(constraints.DEFAULT_CONSTRAINTS[key],
module_level_value)
def test_effective_constraints(self):
@ -552,11 +552,11 @@ class TestConstraintsConfig(unittest.TestCase):
# module level attrs should always mirror the same value as the
# EFFECTIVE map
module_level_value = getattr(constraints, key.upper())
self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key],
self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key],
module_level_value)
# if there are local over-rides in swift.conf those should be
# reflected in the EFFECTIVE, otherwise we expect the DEFAULTs
self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key],
self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key],
constraints.OVERRIDE_CONSTRAINTS.get(
key, constraints.DEFAULT_CONSTRAINTS[key]))
@ -573,13 +573,13 @@ class TestConstraintsConfig(unittest.TestCase):
for key in constraints.DEFAULT_CONSTRAINTS:
# module level attrs should all be 1
module_level_value = getattr(constraints, key.upper())
self.assertEquals(module_level_value, 1)
self.assertEqual(module_level_value, 1)
# all keys should be in OVERRIDE
self.assertEquals(constraints.OVERRIDE_CONSTRAINTS[key],
self.assertEqual(constraints.OVERRIDE_CONSTRAINTS[key],
module_level_value)
# module level attrs should always mirror the same value as
# the EFFECTIVE map
self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS[key],
self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS[key],
module_level_value)
finally:
constraints.reload_constraints()
@ -595,7 +595,7 @@ class TestConstraintsConfig(unittest.TestCase):
with mock.patch.object(utils, 'SWIFT_CONF_FILE', f.name):
constraints.reload_constraints()
self.assertTrue(constraints.SWIFT_CONSTRAINTS_LOADED)
self.assertEquals(sorted(constraints.DEFAULT_CONSTRAINTS.keys()),
self.assertEqual(sorted(constraints.DEFAULT_CONSTRAINTS.keys()),
sorted(constraints.OVERRIDE_CONSTRAINTS.keys()))
# file is now deleted...
with mock.patch.object(utils, 'SWIFT_CONF_FILE', f.name):
@ -603,9 +603,9 @@ class TestConstraintsConfig(unittest.TestCase):
# no constraints have been loaded from non-existent swift.conf
self.assertFalse(constraints.SWIFT_CONSTRAINTS_LOADED)
# no constraints are in OVERRIDE
self.assertEquals([], constraints.OVERRIDE_CONSTRAINTS.keys())
self.assertEqual([], constraints.OVERRIDE_CONSTRAINTS.keys())
# the EFFECTIVE constraints mirror DEFAULT
self.assertEquals(constraints.EFFECTIVE_CONSTRAINTS,
self.assertEqual(constraints.EFFECTIVE_CONSTRAINTS,
constraints.DEFAULT_CONSTRAINTS)
finally:
constraints.reload_constraints()

View File

@ -51,7 +51,7 @@ class TestDaemon(unittest.TestCase):
def test_create(self):
d = daemon.Daemon({})
self.assertEquals(d.conf, {})
self.assertEqual(d.conf, {})
self.assertTrue(isinstance(d.logger, utils.LogAdapter))
def test_stubs(self):
@ -77,20 +77,20 @@ class TestRunDaemon(unittest.TestCase):
self.assertFalse(MyDaemon.once_called)
# test default
d.run()
self.assertEquals(d.forever_called, True)
self.assertEqual(d.forever_called, True)
# test once
d.run(once=True)
self.assertEquals(d.once_called, True)
self.assertEqual(d.once_called, True)
def test_run_daemon(self):
sample_conf = "[my-daemon]\nuser = %s\n" % getuser()
with tmpfile(sample_conf) as conf_file:
with patch.dict('os.environ', {'TZ': ''}):
daemon.run_daemon(MyDaemon, conf_file)
self.assertEquals(MyDaemon.forever_called, True)
self.assertEqual(MyDaemon.forever_called, True)
self.assertTrue(os.environ['TZ'] is not '')
daemon.run_daemon(MyDaemon, conf_file, once=True)
self.assertEquals(MyDaemon.once_called, True)
self.assertEqual(MyDaemon.once_called, True)
# test raise in daemon code
MyDaemon.run_once = MyDaemon.run_raise

View File

@ -70,16 +70,16 @@ class TestDictFactory(unittest.TestCase):
conn.execute('INSERT INTO test (one, two) VALUES ("def", 456)')
conn.commit()
curs = conn.execute('SELECT one, two FROM test')
self.assertEquals(dict_factory(curs, next(curs)),
self.assertEqual(dict_factory(curs, next(curs)),
{'one': 'abc', 'two': 123})
self.assertEquals(dict_factory(curs, next(curs)),
self.assertEqual(dict_factory(curs, next(curs)),
{'one': 'def', 'two': 456})
class TestChexor(unittest.TestCase):
def test_normal_case(self):
self.assertEquals(
self.assertEqual(
chexor('d41d8cd98f00b204e9800998ecf8427e',
'new name', normalize_timestamp(1)),
'4f2ea31ac14d4273fe32ba08062b21de')
@ -459,13 +459,13 @@ class TestExampleBroker(unittest.TestCase):
def test_get_max_row(self):
broker = self.broker_class(':memory:', account='a', container='c')
broker.initialize(next(self.ts), storage_policy_index=int(self.policy))
self.assertEquals(-1, broker.get_max_row())
self.assertEqual(-1, broker.get_max_row())
self.put_item(broker, next(self.ts))
self.assertEquals(1, broker.get_max_row())
self.assertEqual(1, broker.get_max_row())
self.delete_item(broker, next(self.ts))
self.assertEquals(2, broker.get_max_row())
self.assertEqual(2, broker.get_max_row())
self.put_item(broker, next(self.ts))
self.assertEquals(3, broker.get_max_row())
self.assertEqual(3, broker.get_max_row())
def test_get_info(self):
broker = self.broker_class(':memory:', account='test', container='c')
@ -531,9 +531,9 @@ class TestExampleBroker(unittest.TestCase):
with patch('swift.common.db.time.time', new=lambda: created_at):
broker.initialize(put_timestamp,
storage_policy_index=int(self.policy))
self.assertEquals(broker.get_info()['status_changed_at'],
self.assertEqual(broker.get_info()['status_changed_at'],
put_timestamp)
self.assertEquals(broker.get_info()['created_at'],
self.assertEqual(broker.get_info()['created_at'],
Timestamp(created_at).internal)
status_changed_at = next(self.ts)
broker.update_status_changed_at(status_changed_at)
@ -624,7 +624,7 @@ class TestDatabaseBroker(unittest.TestCase):
b = DatabaseBroker(db_file)
b._preallocate()
# We only wrote 1 byte, so we should end with the 1st step or 1 MB.
self.assertEquals(test_size[0], 1024 * 1024)
self.assertEqual(test_size[0], 1024 * 1024)
def test_initialize(self):
self.assertRaises(AttributeError,
@ -642,7 +642,7 @@ class TestDatabaseBroker(unittest.TestCase):
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
self.assertTrue(hasattr(stub_dict['args'][0], 'execute'))
self.assertEquals(stub_dict['args'][1], '0000000001.00000')
self.assertEqual(stub_dict['args'][1], '0000000001.00000')
with broker.get() as conn:
conn.execute('SELECT * FROM outgoing_sync')
conn.execute('SELECT * FROM incoming_sync')
@ -650,7 +650,7 @@ class TestDatabaseBroker(unittest.TestCase):
broker._initialize = stub
broker.initialize(normalize_timestamp('1'))
self.assertTrue(hasattr(stub_dict['args'][0], 'execute'))
self.assertEquals(stub_dict['args'][1], '0000000001.00000')
self.assertEqual(stub_dict['args'][1], '0000000001.00000')
with broker.get() as conn:
conn.execute('SELECT * FROM outgoing_sync')
conn.execute('SELECT * FROM incoming_sync')
@ -727,14 +727,14 @@ class TestDatabaseBroker(unittest.TestCase):
pass
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEquals(
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], [])
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("1")')
conn.commit()
broker = DatabaseBroker(os.path.join(self.testdir, '1.db'))
with broker.get() as conn:
self.assertEquals(
self.assertEqual(
[r[0] for r in conn.execute('SELECT * FROM test')], ['1'])
dbpath = os.path.join(self.testdir, 'dev', 'dbs', 'par', 'pre', 'db')
@ -754,7 +754,7 @@ class TestDatabaseBroker(unittest.TestCase):
conn.execute('SELECT * FROM test')
except Exception as err:
exc = err
self.assertEquals(
self.assertEqual(
str(exc),
'Quarantined %s to %s due to malformed database' %
(dbpath, qpath))
@ -770,7 +770,7 @@ class TestDatabaseBroker(unittest.TestCase):
conn.execute('SELECT * FROM test')
except Exception as err:
exc = err
self.assertEquals(
self.assertEqual(
str(exc),
'Quarantined %s to %s due to corrupted database' %
(dbpath, qpath))
@ -829,39 +829,39 @@ class TestDatabaseBroker(unittest.TestCase):
broker.newid(uuid2)
with broker.get() as conn:
uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')]
self.assertEquals(len(uuids), 1)
self.assertEqual(len(uuids), 1)
self.assertNotEquals(uuids[0], uuid1)
uuid1 = uuids[0]
points = [(r[0], r[1]) for r in conn.execute(
'SELECT sync_point, '
'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid2,))]
self.assertEquals(len(points), 1)
self.assertEquals(points[0][0], -1)
self.assertEquals(points[0][1], uuid2)
self.assertEqual(len(points), 1)
self.assertEqual(points[0][0], -1)
self.assertEqual(points[0][1], uuid2)
conn.execute('INSERT INTO test (one) VALUES ("1")')
conn.commit()
uuid3 = str(uuid4())
broker.newid(uuid3)
with broker.get() as conn:
uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')]
self.assertEquals(len(uuids), 1)
self.assertEqual(len(uuids), 1)
self.assertNotEquals(uuids[0], uuid1)
uuid1 = uuids[0]
points = [(r[0], r[1]) for r in conn.execute(
'SELECT sync_point, '
'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid3,))]
self.assertEquals(len(points), 1)
self.assertEquals(points[0][1], uuid3)
self.assertEqual(len(points), 1)
self.assertEqual(points[0][1], uuid3)
broker.newid(uuid2)
with broker.get() as conn:
uuids = [r[0] for r in conn.execute('SELECT * FROM test_stat')]
self.assertEquals(len(uuids), 1)
self.assertEqual(len(uuids), 1)
self.assertNotEquals(uuids[0], uuid1)
points = [(r[0], r[1]) for r in conn.execute(
'SELECT sync_point, '
'remote_id FROM incoming_sync WHERE remote_id = ?', (uuid2,))]
self.assertEquals(len(points), 1)
self.assertEquals(points[0][1], uuid2)
self.assertEqual(len(points), 1)
self.assertEqual(points[0][1], uuid2)
def test_get_items_since(self):
broker = DatabaseBroker(':memory:')
@ -876,14 +876,14 @@ class TestDatabaseBroker(unittest.TestCase):
conn.commit()
broker._initialize = _initialize
broker.initialize(normalize_timestamp('1'))
self.assertEquals(broker.get_items_since(-1, 10),
self.assertEqual(broker.get_items_since(-1, 10),
[{'one': '1'}, {'one': '2'}, {'one': '3'}])
self.assertEquals(broker.get_items_since(-1, 2),
self.assertEqual(broker.get_items_since(-1, 2),
[{'one': '1'}, {'one': '2'}])
self.assertEquals(broker.get_items_since(1, 2),
self.assertEqual(broker.get_items_since(1, 2),
[{'one': '2'}, {'one': '3'}])
self.assertEquals(broker.get_items_since(3, 2), [])
self.assertEquals(broker.get_items_since(999, 2), [])
self.assertEqual(broker.get_items_since(3, 2), [])
self.assertEqual(broker.get_items_since(999, 2), [])
def test_get_sync(self):
broker = DatabaseBroker(':memory:')
@ -901,29 +901,29 @@ class TestDatabaseBroker(unittest.TestCase):
broker._initialize = _initialize
broker.initialize(normalize_timestamp('1'))
uuid2 = str(uuid4())
self.assertEquals(broker.get_sync(uuid2), -1)
self.assertEqual(broker.get_sync(uuid2), -1)
broker.newid(uuid2)
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid2), 1)
uuid3 = str(uuid4())
self.assertEquals(broker.get_sync(uuid3), -1)
self.assertEqual(broker.get_sync(uuid3), -1)
with broker.get() as conn:
conn.execute('INSERT INTO test (one) VALUES ("2")')
conn.commit()
broker.newid(uuid3)
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEquals(broker.get_sync(uuid3), 2)
self.assertEquals(broker.get_sync(uuid2, incoming=False), -1)
self.assertEquals(broker.get_sync(uuid3, incoming=False), -1)
self.assertEqual(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid3), 2)
self.assertEqual(broker.get_sync(uuid2, incoming=False), -1)
self.assertEqual(broker.get_sync(uuid3, incoming=False), -1)
broker.merge_syncs([{'sync_point': 1, 'remote_id': uuid2}],
incoming=False)
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEquals(broker.get_sync(uuid3), 2)
self.assertEquals(broker.get_sync(uuid2, incoming=False), 1)
self.assertEquals(broker.get_sync(uuid3, incoming=False), -1)
self.assertEqual(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid3), 2)
self.assertEqual(broker.get_sync(uuid2, incoming=False), 1)
self.assertEqual(broker.get_sync(uuid3, incoming=False), -1)
broker.merge_syncs([{'sync_point': 2, 'remote_id': uuid3}],
incoming=False)
self.assertEquals(broker.get_sync(uuid2, incoming=False), 1)
self.assertEquals(broker.get_sync(uuid3, incoming=False), 2)
self.assertEqual(broker.get_sync(uuid2, incoming=False), 1)
self.assertEqual(broker.get_sync(uuid3, incoming=False), 2)
def test_merge_syncs(self):
broker = DatabaseBroker(':memory:')
@ -934,22 +934,22 @@ class TestDatabaseBroker(unittest.TestCase):
broker.initialize(normalize_timestamp('1'))
uuid2 = str(uuid4())
broker.merge_syncs([{'sync_point': 1, 'remote_id': uuid2}])
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid2), 1)
uuid3 = str(uuid4())
broker.merge_syncs([{'sync_point': 2, 'remote_id': uuid3}])
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEquals(broker.get_sync(uuid3), 2)
self.assertEquals(broker.get_sync(uuid2, incoming=False), -1)
self.assertEquals(broker.get_sync(uuid3, incoming=False), -1)
self.assertEqual(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid3), 2)
self.assertEqual(broker.get_sync(uuid2, incoming=False), -1)
self.assertEqual(broker.get_sync(uuid3, incoming=False), -1)
broker.merge_syncs([{'sync_point': 3, 'remote_id': uuid2},
{'sync_point': 4, 'remote_id': uuid3}],
incoming=False)
self.assertEquals(broker.get_sync(uuid2, incoming=False), 3)
self.assertEquals(broker.get_sync(uuid3, incoming=False), 4)
self.assertEquals(broker.get_sync(uuid2), 1)
self.assertEquals(broker.get_sync(uuid3), 2)
self.assertEqual(broker.get_sync(uuid2, incoming=False), 3)
self.assertEqual(broker.get_sync(uuid3, incoming=False), 4)
self.assertEqual(broker.get_sync(uuid2), 1)
self.assertEqual(broker.get_sync(uuid3), 2)
broker.merge_syncs([{'sync_point': 5, 'remote_id': uuid2}])
self.assertEquals(broker.get_sync(uuid2), 5)
self.assertEqual(broker.get_sync(uuid2), 5)
def test_get_replication_info(self):
self.get_replication_info_tester(metadata=False)
@ -1019,7 +1019,7 @@ class TestDatabaseBroker(unittest.TestCase):
put_timestamp = normalize_timestamp(2)
broker.initialize(put_timestamp)
info = broker.get_replication_info()
self.assertEquals(info, {
self.assertEqual(info, {
'account': broker.account, 'count': 0,
'hash': '00000000000000000000000000000000',
'created_at': broker_creation, 'put_timestamp': put_timestamp,
@ -1032,7 +1032,7 @@ class TestDatabaseBroker(unittest.TestCase):
''', (insert_timestamp,))
conn.commit()
info = broker.get_replication_info()
self.assertEquals(info, {
self.assertEqual(info, {
'account': broker.account, 'count': 1,
'hash': 'bdc4c93f574b0d8c2911a27ce9dd38ba',
'created_at': broker_creation, 'put_timestamp': put_timestamp,
@ -1042,7 +1042,7 @@ class TestDatabaseBroker(unittest.TestCase):
conn.execute('DELETE FROM test')
conn.commit()
info = broker.get_replication_info()
self.assertEquals(info, {
self.assertEqual(info, {
'account': broker.account, 'count': 0,
'hash': '00000000000000000000000000000000',
'created_at': broker_creation, 'put_timestamp': put_timestamp,
@ -1062,58 +1062,58 @@ class TestDatabaseBroker(unittest.TestCase):
first_value = '1'
broker.update_metadata({'First': [first_value, first_timestamp]})
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
# Add our second item
second_timestamp = normalize_timestamp(2)
second_value = '2'
broker.update_metadata({'Second': [second_value, second_timestamp]})
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
self.assertEqual(broker.metadata['Second'],
[second_value, second_timestamp])
# Update our first item
first_timestamp = normalize_timestamp(3)
first_value = '1b'
broker.update_metadata({'First': [first_value, first_timestamp]})
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
self.assertEqual(broker.metadata['Second'],
[second_value, second_timestamp])
# Delete our second item (by setting to empty string)
second_timestamp = normalize_timestamp(4)
second_value = ''
broker.update_metadata({'Second': [second_value, second_timestamp]})
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
self.assertEqual(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim at point before second item was deleted
reclaim(broker, normalize_timestamp(3))
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
self.assertEqual(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim at point second item was deleted
reclaim(broker, normalize_timestamp(4))
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' in broker.metadata)
self.assertEquals(broker.metadata['Second'],
self.assertEqual(broker.metadata['Second'],
[second_value, second_timestamp])
# Reclaim after point second item was deleted
reclaim(broker, normalize_timestamp(5))
self.assertTrue('First' in broker.metadata)
self.assertEquals(broker.metadata['First'],
self.assertEqual(broker.metadata['First'],
[first_value, first_timestamp])
self.assertTrue('Second' not in broker.metadata)
@ -1218,7 +1218,7 @@ class TestDatabaseBroker(unittest.TestCase):
try:
broker.possibly_quarantine(*sys.exc_info())
except Exception as exc:
self.assertEquals(
self.assertEqual(
str(exc),
'Quarantined %s to %s due to disk error '
'while accessing database' %

View File

@ -287,8 +287,8 @@ class TestDBReplicator(unittest.TestCase):
logging.getLogger())
def req(method, path, body, headers):
self.assertEquals(method, 'REPLICATE')
self.assertEquals(headers['Content-Type'], 'application/json')
self.assertEqual(method, 'REPLICATE')
self.assertEqual(headers['Content-Type'], 'application/json')
class Resp(object):
def read(self):
@ -296,21 +296,21 @@ class TestDBReplicator(unittest.TestCase):
resp = Resp()
conn.request = req
conn.getresponse = lambda *args: resp
self.assertEquals(conn.replicate(1, 2, 3), resp)
self.assertEqual(conn.replicate(1, 2, 3), resp)
def other_req(method, path, body, headers):
raise Exception('blah')
conn.request = other_req
self.assertEquals(conn.replicate(1, 2, 3), None)
self.assertEqual(conn.replicate(1, 2, 3), None)
def test_rsync_file(self):
replicator = TestReplicator({})
with _mock_process(-1):
self.assertEquals(
self.assertEqual(
False,
replicator._rsync_file('/some/file', 'remote:/some/file'))
with _mock_process(0):
self.assertEquals(
self.assertEqual(
True,
replicator._rsync_file('/some/file', 'remote:/some/file'))
@ -414,11 +414,11 @@ class TestDBReplicator(unittest.TestCase):
different_region=False):
self_._rsync_file_call_count += 1
if self_._rsync_file_call_count == 1:
self.assertEquals(True, whole_file)
self.assertEquals(False, self_.broker.locked)
self.assertEqual(True, whole_file)
self.assertEqual(False, self_.broker.locked)
elif self_._rsync_file_call_count == 2:
self.assertEquals(False, whole_file)
self.assertEquals(True, self_.broker.locked)
self.assertEqual(False, whole_file)
self.assertEqual(True, self_.broker.locked)
else:
raise RuntimeError('_rsync_file() called too many times')
return True
@ -430,7 +430,7 @@ class TestDBReplicator(unittest.TestCase):
fake_device = {'ip': '127.0.0.1', 'replication_ip': '127.0.0.1',
'device': 'sda1'}
replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd')
self.assertEquals(2, replicator._rsync_file_call_count)
self.assertEqual(2, replicator._rsync_file_call_count)
# with new mtime
with patch('os.path.exists', lambda *args: False):
@ -441,19 +441,19 @@ class TestDBReplicator(unittest.TestCase):
'replication_ip': '127.0.0.1',
'device': 'sda1'}
replicator._rsync_db(broker, fake_device, ReplHttp(), 'abcd')
self.assertEquals(2, replicator._rsync_file_call_count)
self.assertEqual(2, replicator._rsync_file_call_count)
def test_in_sync(self):
replicator = TestReplicator({})
self.assertEquals(replicator._in_sync(
self.assertEqual(replicator._in_sync(
{'id': 'a', 'point': 0, 'max_row': 0, 'hash': 'b'},
{'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'b'},
FakeBroker(), -1), True)
self.assertEquals(replicator._in_sync(
self.assertEqual(replicator._in_sync(
{'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'b'},
{'id': 'a', 'point': -1, 'max_row': 10, 'hash': 'b'},
FakeBroker(), -1), True)
self.assertEquals(bool(replicator._in_sync(
self.assertEqual(bool(replicator._in_sync(
{'id': 'a', 'point': -1, 'max_row': 0, 'hash': 'c'},
{'id': 'a', 'point': -1, 'max_row': 10, 'hash': 'd'},
FakeBroker(), -1)), False)
@ -483,7 +483,7 @@ class TestDBReplicator(unittest.TestCase):
self.assertEqual(replicator.port, 6000)
def mock_ismount(path):
self.assertEquals(path,
self.assertEqual(path,
os.path.join(replicator.root,
replicator.ring.devs[0]['device']))
return False
@ -504,16 +504,16 @@ class TestDBReplicator(unittest.TestCase):
self.assertEqual(replicator.port, 6000)
def mock_unlink_older_than(path, mtime):
self.assertEquals(path,
self.assertEqual(path,
os.path.join(replicator.root,
replicator.ring.devs[0]['device'],
'tmp'))
self.assertTrue(time.time() - replicator.reclaim_age >= mtime)
def mock_spawn_n(fn, part, object_file, node_id):
self.assertEquals('123', part)
self.assertEquals('/srv/node/sda/c.db', object_file)
self.assertEquals(1, node_id)
self.assertEqual('123', part)
self.assertEqual('/srv/node/sda/c.db', object_file)
self.assertEqual(1, node_id)
self._patch(patch.object, db_replicator, 'whataremyips',
lambda *a, **kw: ['1.1.1.1'])
@ -562,7 +562,7 @@ class TestDBReplicator(unittest.TestCase):
replicator = TestReplicator({})
replicator.delete_db = self.stub_delete_db
replicator._replicate_object('0', '/path/to/file', 'node_id')
self.assertEquals([], self.delete_db_calls)
self.assertEqual([], self.delete_db_calls)
def test_replicate_object_quarantine(self):
replicator = TestReplicator({})
@ -574,12 +574,12 @@ class TestDBReplicator(unittest.TestCase):
def mock_renamer(was, new, fsync=False, cause_colision=False):
if cause_colision and '-' not in new:
raise OSError(errno.EEXIST, "File already exists")
self.assertEquals('/a/b/c/d/e', was)
self.assertEqual('/a/b/c/d/e', was)
if '-' in new:
self.assertTrue(
new.startswith('/a/quarantined/containers/e-'))
else:
self.assertEquals('/a/quarantined/containers/e', new)
self.assertEqual('/a/quarantined/containers/e', new)
def mock_renamer_error(was, new, fsync):
return mock_renamer(was, new, fsync, cause_colision=True)
@ -598,13 +598,13 @@ class TestDBReplicator(unittest.TestCase):
replicator._replicate_object('0', '/path/to/file', 'node_id')
finally:
replicator.brokerclass.stub_replication_info = None
self.assertEquals(['/path/to/file'], self.delete_db_calls)
self.assertEqual(['/path/to/file'], self.delete_db_calls)
def test_replicate_object_delete_because_not_shouldbehere(self):
replicator = TestReplicator({})
replicator.delete_db = self.stub_delete_db
replicator._replicate_object('0', '/path/to/file', 'node_id')
self.assertEquals(['/path/to/file'], self.delete_db_calls)
self.assertEqual(['/path/to/file'], self.delete_db_calls)
def test_replicate_account_out_of_place(self):
replicator = TestReplicator({}, logger=unit.FakeLogger())
@ -718,28 +718,28 @@ class TestDBReplicator(unittest.TestCase):
def test_dispatch_no_arg_pop(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
response = rpc.dispatch(('a',), 'arg')
self.assertEquals('Invalid object type', response.body)
self.assertEquals(400, response.status_int)
self.assertEqual('Invalid object type', response.body)
self.assertEqual(400, response.status_int)
def test_dispatch_drive_not_mounted(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, True)
def mock_ismount(path):
self.assertEquals('/drive', path)
self.assertEqual('/drive', path)
return False
self._patch(patch.object, db_replicator, 'ismount', mock_ismount)
response = rpc.dispatch(('drive', 'part', 'hash'), ['method'])
self.assertEquals('507 drive is not mounted', response.status)
self.assertEquals(507, response.status_int)
self.assertEqual('507 drive is not mounted', response.status)
self.assertEqual(507, response.status_int)
def test_dispatch_unexpected_operation_db_does_not_exist(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
def mock_mkdirs(path):
self.assertEquals('/drive/tmp', path)
self.assertEqual('/drive/tmp', path)
self._patch(patch.object, db_replicator, 'mkdirs', mock_mkdirs)
@ -748,8 +748,8 @@ class TestDBReplicator(unittest.TestCase):
mock_os.path.exists.return_value = False
response = rpc.dispatch(('drive', 'part', 'hash'), ['unexpected'])
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
def test_dispatch_operation_unexpected(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -757,7 +757,7 @@ class TestDBReplicator(unittest.TestCase):
self._patch(patch.object, db_replicator, 'mkdirs', lambda *args: True)
def unexpected_method(broker, args):
self.assertEquals(FakeBroker, broker.__class__)
self.assertEqual(FakeBroker, broker.__class__)
self.assertEqual(['arg1', 'arg2'], args)
return 'unexpected-called'
@ -770,7 +770,7 @@ class TestDBReplicator(unittest.TestCase):
['unexpected', 'arg1', 'arg2'])
mock_os.path.exists.assert_called_with('/part/ash/hash/hash.db')
self.assertEquals('unexpected-called', response)
self.assertEqual('unexpected-called', response)
def test_dispatch_operation_rsync_then_merge(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -784,10 +784,10 @@ class TestDBReplicator(unittest.TestCase):
['rsync_then_merge', 'arg1', 'arg2'])
expected_calls = [call('/part/ash/hash/hash.db'),
call('/drive/tmp/arg1')]
self.assertEquals(mock_os.path.exists.call_args_list,
self.assertEqual(mock_os.path.exists.call_args_list,
expected_calls)
self.assertEquals('204 No Content', response.status)
self.assertEquals(204, response.status_int)
self.assertEqual('204 No Content', response.status)
self.assertEqual(204, response.status_int)
def test_dispatch_operation_complete_rsync(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -801,10 +801,10 @@ class TestDBReplicator(unittest.TestCase):
['complete_rsync', 'arg1', 'arg2'])
expected_calls = [call('/part/ash/hash/hash.db'),
call('/drive/tmp/arg1')]
self.assertEquals(mock_os.path.exists.call_args_list,
self.assertEqual(mock_os.path.exists.call_args_list,
expected_calls)
self.assertEquals('204 No Content', response.status)
self.assertEquals(204, response.status_int)
self.assertEqual('204 No Content', response.status)
self.assertEqual(204, response.status_int)
def test_rsync_then_merge_db_does_not_exist(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -815,8 +815,8 @@ class TestDBReplicator(unittest.TestCase):
response = rpc.rsync_then_merge('drive', '/data/db.db',
('arg1', 'arg2'))
mock_os.path.exists.assert_called_with('/data/db.db')
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
def test_rsync_then_merge_old_does_not_exist(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -827,17 +827,17 @@ class TestDBReplicator(unittest.TestCase):
response = rpc.rsync_then_merge('drive', '/data/db.db',
('arg1', 'arg2'))
expected_calls = [call('/data/db.db'), call('/drive/tmp/arg1')]
self.assertEquals(mock_os.path.exists.call_args_list,
self.assertEqual(mock_os.path.exists.call_args_list,
expected_calls)
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
def test_rsync_then_merge_with_objects(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
def mock_renamer(old, new):
self.assertEquals('/drive/tmp/arg1', old)
self.assertEquals('/data/db.db', new)
self.assertEqual('/drive/tmp/arg1', old)
self.assertEqual('/data/db.db', new)
self._patch(patch.object, db_replicator, 'renamer', mock_renamer)
@ -846,8 +846,8 @@ class TestDBReplicator(unittest.TestCase):
mock_os.path.exists.return_value = True
response = rpc.rsync_then_merge('drive', '/data/db.db',
['arg1', 'arg2'])
self.assertEquals('204 No Content', response.status)
self.assertEquals(204, response.status_int)
self.assertEqual('204 No Content', response.status)
self.assertEqual(204, response.status_int)
def test_complete_rsync_db_does_not_exist(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -858,8 +858,8 @@ class TestDBReplicator(unittest.TestCase):
response = rpc.complete_rsync('drive', '/data/db.db',
['arg1', 'arg2'])
mock_os.path.exists.assert_called_with('/data/db.db')
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
def test_complete_rsync_old_file_does_not_exist(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -870,10 +870,10 @@ class TestDBReplicator(unittest.TestCase):
response = rpc.complete_rsync('drive', '/data/db.db',
['arg1', 'arg2'])
expected_calls = [call('/data/db.db'), call('/drive/tmp/arg1')]
self.assertEquals(expected_calls,
self.assertEqual(expected_calls,
mock_os.path.exists.call_args_list)
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
def test_complete_rsync_rename(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -881,12 +881,12 @@ class TestDBReplicator(unittest.TestCase):
def mock_exists(path):
if path == '/data/db.db':
return False
self.assertEquals('/drive/tmp/arg1', path)
self.assertEqual('/drive/tmp/arg1', path)
return True
def mock_renamer(old, new):
self.assertEquals('/drive/tmp/arg1', old)
self.assertEquals('/data/db.db', new)
self.assertEqual('/drive/tmp/arg1', old)
self.assertEqual('/data/db.db', new)
self._patch(patch.object, db_replicator, 'renamer', mock_renamer)
@ -895,8 +895,8 @@ class TestDBReplicator(unittest.TestCase):
mock_os.path.exists.side_effect = [False, True]
response = rpc.complete_rsync('drive', '/data/db.db',
['arg1', 'arg2'])
self.assertEquals('204 No Content', response.status)
self.assertEquals(204, response.status_int)
self.assertEqual('204 No Content', response.status)
self.assertEqual(204, response.status_int)
def test_replicator_sync_with_broker_replication_missing_table(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -908,8 +908,8 @@ class TestDBReplicator(unittest.TestCase):
def mock_quarantine_db(object_file, server_type):
called.append(True)
self.assertEquals(broker.db_file, object_file)
self.assertEquals(broker.db_type, server_type)
self.assertEqual(broker.db_file, object_file)
self.assertEqual(broker.db_type, server_type)
self._patch(patch.object, db_replicator, 'quarantine_db',
mock_quarantine_db)
@ -918,8 +918,8 @@ class TestDBReplicator(unittest.TestCase):
'created_at', 'put_timestamp',
'delete_timestamp', 'metadata'))
self.assertEquals('404 Not Found', response.status)
self.assertEquals(404, response.status_int)
self.assertEqual('404 Not Found', response.status)
self.assertEqual(404, response.status_int)
self.assertEqual(called, [True])
errors = rpc.logger.get_lines_for_level('error')
self.assertEqual(errors,
@ -935,14 +935,14 @@ class TestDBReplicator(unittest.TestCase):
'delete_timestamp',
'{"meta1": "data1", "meta2": "data2"}'))
self.assertEquals({'meta1': 'data1', 'meta2': 'data2'},
self.assertEqual({'meta1': 'data1', 'meta2': 'data2'},
broker.metadata)
self.assertEquals('created_at', broker.created_at)
self.assertEquals('put_timestamp', broker.put_timestamp)
self.assertEquals('delete_timestamp', broker.delete_timestamp)
self.assertEqual('created_at', broker.created_at)
self.assertEqual('put_timestamp', broker.put_timestamp)
self.assertEqual('delete_timestamp', broker.delete_timestamp)
self.assertEquals('200 OK', response.status)
self.assertEquals(200, response.status_int)
self.assertEqual('200 OK', response.status)
self.assertEqual(200, response.status_int)
def test_rsync_then_merge(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
@ -953,14 +953,14 @@ class TestDBReplicator(unittest.TestCase):
fake_broker = FakeBroker()
args = ('a', 'b')
rpc.merge_items(fake_broker, args)
self.assertEquals(fake_broker.args, args)
self.assertEqual(fake_broker.args, args)
def test_merge_syncs(self):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
fake_broker = FakeBroker()
args = ('a', 'b')
rpc.merge_syncs(fake_broker, args)
self.assertEquals(fake_broker.args, (args[0],))
self.assertEqual(fake_broker.args, (args[0],))
def test_complete_rsync_with_bad_input(self):
drive = '/some/root'
@ -969,10 +969,10 @@ class TestDBReplicator(unittest.TestCase):
rpc = db_replicator.ReplicatorRpc('/', '/', FakeBroker, False)
resp = rpc.complete_rsync(drive, db_file, args)
self.assertTrue(isinstance(resp, HTTPException))
self.assertEquals(404, resp.status_int)
self.assertEqual(404, resp.status_int)
resp = rpc.complete_rsync(drive, 'new_db_file', args)
self.assertTrue(isinstance(resp, HTTPException))
self.assertEquals(404, resp.status_int)
self.assertEqual(404, resp.status_int)
def test_complete_rsync(self):
drive = mkdtemp()
@ -986,7 +986,7 @@ class TestDBReplicator(unittest.TestCase):
fp.write('void')
fp.close
resp = rpc.complete_rsync(drive, new_file, args)
self.assertEquals(204, resp.status_int)
self.assertEqual(204, resp.status_int)
finally:
rmtree(drive)
@ -1076,7 +1076,7 @@ class TestDBReplicator(unittest.TestCase):
results = list(db_replicator.roundrobin_datadirs(datadirs))
# The results show that the .db files are returned, the devices
# interleaved.
self.assertEquals(results, [
self.assertEqual(results, [
('123', '/srv/node/sda/containers/123/abc/'
'00000000000000000000000000000abc/'
'00000000000000000000000000000abc.db', 1),
@ -1090,7 +1090,7 @@ class TestDBReplicator(unittest.TestCase):
'22222222222222222222222222222ghi/'
'22222222222222222222222222222ghi.db', 2)])
# The listdir calls show that we only listdir the dirs
self.assertEquals(listdir_calls, [
self.assertEqual(listdir_calls, [
'/srv/node/sda/containers',
'/srv/node/sda/containers/123',
'/srv/node/sda/containers/123/abc',
@ -1105,7 +1105,7 @@ class TestDBReplicator(unittest.TestCase):
'/srv/node/sdb/containers/9999'])
# The isdir calls show that we did ask about the things pretending
# to be files at various levels.
self.assertEquals(isdir_calls, [
self.assertEqual(isdir_calls, [
'/srv/node/sda/containers/123',
'/srv/node/sda/containers/123/abc',
('/srv/node/sda/containers/123/abc/'
@ -1140,7 +1140,7 @@ class TestDBReplicator(unittest.TestCase):
'/srv/node/sdb/containers/9999'])
# The exists calls are the .db files we looked for as we walked the
# structure.
self.assertEquals(exists_calls, [
self.assertEqual(exists_calls, [
('/srv/node/sda/containers/123/abc/'
'00000000000000000000000000000abc/'
'00000000000000000000000000000abc.db'),
@ -1154,12 +1154,12 @@ class TestDBReplicator(unittest.TestCase):
'22222222222222222222222222222ghi/'
'22222222222222222222222222222ghi.db')])
# Shows that we called shuffle twice, once for each device.
self.assertEquals(
self.assertEqual(
shuffle_calls, [['123', '456', '789', '9999'],
['123', '456', '789', '9999']])
# Shows that we called removed the two empty partition directories.
self.assertEquals(
self.assertEqual(
rmdir_calls, ['/srv/node/sda/containers/9999',
'/srv/node/sdb/containers/9999'])
finally:
@ -1204,7 +1204,7 @@ class TestReplToNode(unittest.TestCase):
rinfo = {"id": 3, "point": -1, "max_row": 5, "hash": "c"}
self.http = ReplHttp(simplejson.dumps(rinfo))
local_sync = self.broker.get_sync()
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, self.broker, '0', self.fake_info), True)
self.replicator._usync_db.assert_has_calls([
mock.call(max(rinfo['point'], local_sync), self.broker,
@ -1215,7 +1215,7 @@ class TestReplToNode(unittest.TestCase):
rinfo = {"id": 3, "point": -1, "max_row": 4, "hash": "c"}
self.http = ReplHttp(simplejson.dumps(rinfo))
self.broker.get_sync()
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, self.broker, '0', self.fake_info), True)
self.replicator.logger.increment.assert_has_calls([
mock.call.increment('remote_merges')
@ -1232,14 +1232,14 @@ class TestReplToNode(unittest.TestCase):
rinfo = {"id": 3, "point": -1, "max_row": 10, "hash": "b"}
self.http = ReplHttp(simplejson.dumps(rinfo))
self.broker.get_sync()
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, self.broker, '0', self.fake_info), True)
self.assertEquals(self.replicator._rsync_db.call_count, 0)
self.assertEquals(self.replicator._usync_db.call_count, 0)
self.assertEqual(self.replicator._rsync_db.call_count, 0)
self.assertEqual(self.replicator._usync_db.call_count, 0)
def test_repl_to_node_not_found(self):
self.http = ReplHttp('{"id": 3, "point": -1}', set_status=404)
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, self.broker, '0', self.fake_info, False), True)
self.replicator.logger.increment.assert_has_calls([
mock.call.increment('rsyncs')
@ -1258,12 +1258,12 @@ class TestReplToNode(unittest.TestCase):
def test_repl_to_node_300_status(self):
self.http = ReplHttp('{"id": 3, "point": -1}', set_status=300)
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, FakeBroker(), '0', self.fake_info), None)
def test_repl_to_node_not_response(self):
self.http = mock.Mock(replicate=mock.Mock(return_value=None))
self.assertEquals(self.replicator._repl_to_node(
self.assertEqual(self.replicator._repl_to_node(
self.fake_node, FakeBroker(), '0', self.fake_info), False)

View File

@ -90,9 +90,9 @@ class GetMetadataInternalClient(internal_client.InternalClient):
def _get_metadata(self, path, metadata_prefix, acceptable_statuses=None,
headers=None):
self.get_metadata_called += 1
self.test.assertEquals(self.path, path)
self.test.assertEquals(self.metadata_prefix, metadata_prefix)
self.test.assertEquals(self.acceptable_statuses, acceptable_statuses)
self.test.assertEqual(self.path, path)
self.test.assertEqual(self.metadata_prefix, metadata_prefix)
self.test.assertEqual(self.acceptable_statuses, acceptable_statuses)
return self.metadata
@ -111,10 +111,10 @@ class SetMetadataInternalClient(internal_client.InternalClient):
self, path, metadata, metadata_prefix='',
acceptable_statuses=None):
self.set_metadata_called += 1
self.test.assertEquals(self.path, path)
self.test.assertEquals(self.metadata_prefix, metadata_prefix)
self.test.assertEquals(self.metadata, metadata)
self.test.assertEquals(self.acceptable_statuses, acceptable_statuses)
self.test.assertEqual(self.path, path)
self.test.assertEqual(self.metadata_prefix, metadata_prefix)
self.test.assertEqual(self.metadata, metadata)
self.test.assertEqual(self.acceptable_statuses, acceptable_statuses)
class IterInternalClient(internal_client.InternalClient):
@ -129,10 +129,10 @@ class IterInternalClient(internal_client.InternalClient):
def _iter_items(
self, path, marker='', end_marker='', acceptable_statuses=None):
self.test.assertEquals(self.path, path)
self.test.assertEquals(self.marker, marker)
self.test.assertEquals(self.end_marker, end_marker)
self.test.assertEquals(self.acceptable_statuses, acceptable_statuses)
self.test.assertEqual(self.path, path)
self.test.assertEqual(self.marker, marker)
self.test.assertEqual(self.end_marker, end_marker)
self.test.assertEqual(self.acceptable_statuses, acceptable_statuses)
for item in self.items:
yield item
@ -145,7 +145,7 @@ class TestCompressingfileReader(unittest.TestCase):
self.args = args
def method(self, *args):
self.test.assertEquals(self.args, args)
self.test.assertEqual(self.args, args)
return self
try:
@ -158,12 +158,12 @@ class TestCompressingfileReader(unittest.TestCase):
f = StringIO('')
fobj = internal_client.CompressingFileReader(f)
self.assertEquals(f, fobj._f)
self.assertEquals(compressobj, fobj._compressor)
self.assertEquals(False, fobj.done)
self.assertEquals(True, fobj.first)
self.assertEquals(0, fobj.crc32)
self.assertEquals(0, fobj.total_size)
self.assertEqual(f, fobj._f)
self.assertEqual(compressobj, fobj._compressor)
self.assertEqual(False, fobj.done)
self.assertEqual(True, fobj.first)
self.assertEqual(0, fobj.crc32)
self.assertEqual(0, fobj.total_size)
finally:
internal_client.compressobj = old_compressobj
@ -177,7 +177,7 @@ class TestCompressingfileReader(unittest.TestCase):
for chunk in fobj.read():
data += d.decompress(chunk)
self.assertEquals(exp_data, data)
self.assertEqual(exp_data, data)
def test_seek(self):
exp_data = 'abcdefghijklmnopqrstuvwxyz'
@ -194,7 +194,7 @@ class TestCompressingfileReader(unittest.TestCase):
d = zlib.decompressobj(16 + zlib.MAX_WBITS)
for chunk in fobj.read():
data += d.decompress(chunk)
self.assertEquals(exp_data, data)
self.assertEqual(exp_data, data)
def test_seek_not_implemented_exception(self):
fobj = internal_client.CompressingFileReader(
@ -249,7 +249,7 @@ class TestInternalClient(unittest.TestCase):
object_ring)
self.assertEqual(object_ring.serialized_path,
object_ring_path)
self.assertEquals(client.auto_create_account_prefix, '-')
self.assertEqual(client.auto_create_account_prefix, '-')
def test_init(self):
class App(object):
@ -260,7 +260,7 @@ class TestInternalClient(unittest.TestCase):
def load(self, uri, allow_modify_pipeline=True):
self.load_called += 1
self.test.assertEquals(conf_path, uri)
self.test.assertEqual(conf_path, uri)
self.test.assertFalse(allow_modify_pipeline)
return self
@ -278,10 +278,10 @@ class TestInternalClient(unittest.TestCase):
finally:
internal_client.loadapp = old_loadapp
self.assertEquals(1, app.load_called)
self.assertEquals(app, client.app)
self.assertEquals(user_agent, client.user_agent)
self.assertEquals(request_tries, client.request_tries)
self.assertEqual(1, app.load_called)
self.assertEqual(app, client.app)
self.assertEqual(user_agent, client.user_agent)
self.assertEqual(request_tries, client.request_tries)
def test_make_request_sets_user_agent(self):
class InternalClient(internal_client.InternalClient):
@ -292,7 +292,7 @@ class TestInternalClient(unittest.TestCase):
self.request_tries = 1
def fake_app(self, env, start_response):
self.test.assertEquals(self.user_agent, env['HTTP_USER_AGENT'])
self.test.assertEqual(self.user_agent, env['HTTP_USER_AGENT'])
start_response('200 Ok', [('Content-Length', '0')])
return []
@ -320,7 +320,7 @@ class TestInternalClient(unittest.TestCase):
def sleep(self, seconds):
self.sleep_called += 1
self.test.assertEquals(2 ** (self.sleep_called), seconds)
self.test.assertEqual(2 ** (self.sleep_called), seconds)
client = InternalClient(self)
@ -332,8 +332,8 @@ class TestInternalClient(unittest.TestCase):
finally:
internal_client.sleep = old_sleep
self.assertEquals(3, client.sleep_called)
self.assertEquals(4, client.tries)
self.assertEqual(3, client.sleep_called)
self.assertEqual(4, client.tries)
def test_base_request_timeout(self):
# verify that base_request passes timeout arg on to urlopen
@ -351,7 +351,7 @@ class TestInternalClient(unittest.TestCase):
_, resp_body = sc.base_request('GET', timeout=timeout)
mock_urlopen.assert_called_once_with(mock.ANY, timeout=timeout)
# sanity check
self.assertEquals(body, resp_body)
self.assertEqual(body, resp_body)
def test_make_request_method_path_headers(self):
class InternalClient(internal_client.InternalClient):
@ -370,12 +370,12 @@ class TestInternalClient(unittest.TestCase):
for method in 'GET PUT HEAD'.split():
client.make_request(method, '/', {}, (200,))
self.assertEquals(client.env['REQUEST_METHOD'], method)
self.assertEqual(client.env['REQUEST_METHOD'], method)
for path in '/one /two/three'.split():
client.make_request('GET', path, {'X-Test': path}, (200,))
self.assertEquals(client.env['PATH_INFO'], path)
self.assertEquals(client.env['HTTP_X_TEST'], path)
self.assertEqual(client.env['PATH_INFO'], path)
self.assertEqual(client.env['HTTP_X_TEST'], path)
def test_make_request_codes(self):
class InternalClient(internal_client.InternalClient):
@ -403,12 +403,12 @@ class TestInternalClient(unittest.TestCase):
client.make_request('GET', '/', {}, (400,))
except Exception as err:
pass
self.assertEquals(200, err.resp.status_int)
self.assertEqual(200, err.resp.status_int)
try:
client.make_request('GET', '/', {}, (201,))
except Exception as err:
pass
self.assertEquals(200, err.resp.status_int)
self.assertEqual(200, err.resp.status_int)
try:
client.make_request('GET', '/', {}, (111,))
except Exception as err:
@ -426,8 +426,8 @@ class TestInternalClient(unittest.TestCase):
def seek(self, offset, whence=0):
self.seek_called += 1
self.test.assertEquals(0, offset)
self.test.assertEquals(0, whence)
self.test.assertEqual(0, offset)
self.test.assertEqual(0, whence)
class InternalClient(internal_client.InternalClient):
def __init__(self):
@ -449,11 +449,11 @@ class TestInternalClient(unittest.TestCase):
client.make_request('PUT', '/', {}, (2,), fobj)
except Exception as err:
pass
self.assertEquals(404, err.resp.status_int)
self.assertEqual(404, err.resp.status_int)
finally:
internal_client.sleep = old_sleep
self.assertEquals(client.request_tries, fobj.seek_called)
self.assertEqual(client.request_tries, fobj.seek_called)
def test_make_request_request_exception(self):
class InternalClient(internal_client.InternalClient):
@ -491,10 +491,10 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('HEAD', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals((2,), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('HEAD', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual((2,), acceptable_statuses)
self.test.assertEqual(None, body_file)
return Response(self.resp_headers)
path = 'some_path'
@ -514,8 +514,8 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, path, resp_headers)
metadata = client._get_metadata(path, metadata_prefix)
self.assertEquals(exp_metadata, metadata)
self.assertEquals(1, client.make_request_called)
self.assertEqual(exp_metadata, metadata)
self.assertEqual(1, client.make_request_called)
def test_get_metadata_invalid_status(self):
class FakeApp(object):
@ -542,7 +542,7 @@ class TestInternalClient(unittest.TestCase):
path = make_path(account, container, obj)
c = InternalClient()
self.assertEquals(path, c.make_path(account, container, obj))
self.assertEqual(path, c.make_path(account, container, obj))
def test_make_path_exception(self):
c = InternalClient()
@ -572,7 +572,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, responses)
for item in client._iter_items('/'):
items.append(item)
self.assertEquals(exp_items, items)
self.assertEqual(exp_items, items)
exp_items = []
responses = []
@ -588,7 +588,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, responses)
for item in client._iter_items('/'):
items.append(item)
self.assertEquals(exp_items, items)
self.assertEqual(exp_items, items)
def test_iter_items_with_markers(self):
class Response(object):
@ -606,7 +606,7 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
exp_path = self.paths.pop(0)
self.test.assertEquals(exp_path, path)
self.test.assertEqual(exp_path, path)
return self.responses.pop(0)
paths = [
@ -626,7 +626,7 @@ class TestInternalClient(unittest.TestCase):
for item in client._iter_items('/', marker='start', end_marker='end'):
items.append(item['name'].encode('utf8'))
self.assertEquals('one\xc3\xa9 two'.split(), items)
self.assertEqual('one\xc3\xa9 two'.split(), items)
def test_set_metadata(self):
class InternalClient(internal_client.InternalClient):
@ -640,11 +640,11 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('POST', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals(self.exp_headers, headers)
self.test.assertEquals((2,), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('POST', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual(self.exp_headers, headers)
self.test.assertEqual((2,), acceptable_statuses)
self.test.assertEqual(None, body_file)
path = 'some_path'
metadata_prefix = 'some_key-'
@ -661,7 +661,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, path, exp_headers)
client._set_metadata(path, metadata, metadata_prefix)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
def test_iter_containers(self):
account, container, obj = path_parts()
@ -677,7 +677,7 @@ class TestInternalClient(unittest.TestCase):
account, marker, end_marker,
acceptable_statuses=acceptable_statuses):
ret_items.append(container)
self.assertEquals(items, ret_items)
self.assertEqual(items, ret_items)
def test_get_account_info(self):
class Response(object):
@ -697,11 +697,11 @@ class TestInternalClient(unittest.TestCase):
def make_request(
self, method, path, headers, acceptable_statuses,
body_file=None):
self.test.assertEquals('HEAD', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals({}, headers)
self.test.assertEquals((2, 404), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('HEAD', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual({}, headers)
self.test.assertEqual((2, 404), acceptable_statuses)
self.test.assertEqual(None, body_file)
return self.resp
account, container, obj = path_parts()
@ -709,7 +709,7 @@ class TestInternalClient(unittest.TestCase):
containers, objects = 10, 100
client = InternalClient(self, path, Response(containers, objects))
info = client.get_account_info(account)
self.assertEquals((containers, objects), info)
self.assertEqual((containers, objects), info)
def test_get_account_info_404(self):
class Response(object):
@ -732,7 +732,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient()
info = client.get_account_info('some_account')
self.assertEquals((0, 0), info)
self.assertEqual((0, 0), info)
def test_get_account_metadata(self):
account, container, obj = path_parts()
@ -743,8 +743,8 @@ class TestInternalClient(unittest.TestCase):
self, path, metadata_prefix, acceptable_statuses)
metadata = client.get_account_metadata(
account, metadata_prefix, acceptable_statuses)
self.assertEquals(client.metadata, metadata)
self.assertEquals(1, client.get_metadata_called)
self.assertEqual(client.metadata, metadata)
self.assertEqual(1, client.get_metadata_called)
def test_get_metadadata_with_acceptable_status(self):
account, container, obj = path_parts()
@ -776,7 +776,7 @@ class TestInternalClient(unittest.TestCase):
self, path, metadata, metadata_prefix, acceptable_statuses)
client.set_account_metadata(
account, metadata, metadata_prefix, acceptable_statuses)
self.assertEquals(1, client.set_metadata_called)
self.assertEqual(1, client.set_metadata_called)
def test_container_exists(self):
class Response(object):
@ -794,23 +794,23 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('HEAD', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals({}, headers)
self.test.assertEquals((2, 404), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('HEAD', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual({}, headers)
self.test.assertEqual((2, 404), acceptable_statuses)
self.test.assertEqual(None, body_file)
return self.resp
account, container, obj = path_parts()
path = make_path(account, container)
client = InternalClient(self, path, Response(200))
self.assertEquals(True, client.container_exists(account, container))
self.assertEquals(1, client.make_request_called)
self.assertEqual(True, client.container_exists(account, container))
self.assertEqual(1, client.make_request_called)
client = InternalClient(self, path, Response(404))
self.assertEquals(False, client.container_exists(account, container))
self.assertEquals(1, client.make_request_called)
self.assertEqual(False, client.container_exists(account, container))
self.assertEqual(1, client.make_request_called)
def test_create_container(self):
class InternalClient(internal_client.InternalClient):
@ -824,18 +824,18 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('PUT', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals(self.headers, headers)
self.test.assertEquals((2,), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('PUT', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual(self.headers, headers)
self.test.assertEqual((2,), acceptable_statuses)
self.test.assertEqual(None, body_file)
account, container, obj = path_parts()
path = make_path(account, container)
headers = 'some_headers'
client = InternalClient(self, path, headers)
client.create_container(account, container, headers)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
def test_delete_container(self):
class InternalClient(internal_client.InternalClient):
@ -848,17 +848,17 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('DELETE', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals({}, headers)
self.test.assertEquals((2, 404), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('DELETE', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual({}, headers)
self.test.assertEqual((2, 404), acceptable_statuses)
self.test.assertEqual(None, body_file)
account, container, obj = path_parts()
path = make_path(account, container)
client = InternalClient(self, path)
client.delete_container(account, container)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
def test_get_container_metadata(self):
account, container, obj = path_parts()
@ -869,8 +869,8 @@ class TestInternalClient(unittest.TestCase):
self, path, metadata_prefix, acceptable_statuses)
metadata = client.get_container_metadata(
account, container, metadata_prefix, acceptable_statuses)
self.assertEquals(client.metadata, metadata)
self.assertEquals(1, client.get_metadata_called)
self.assertEqual(client.metadata, metadata)
self.assertEqual(1, client.get_metadata_called)
def test_iter_objects(self):
account, container, obj = path_parts()
@ -885,7 +885,7 @@ class TestInternalClient(unittest.TestCase):
for obj in client.iter_objects(
account, container, marker, end_marker, acceptable_statuses):
ret_items.append(obj)
self.assertEquals(items, ret_items)
self.assertEqual(items, ret_items)
def test_set_container_metadata(self):
account, container, obj = path_parts()
@ -897,7 +897,7 @@ class TestInternalClient(unittest.TestCase):
self, path, metadata, metadata_prefix, acceptable_statuses)
client.set_container_metadata(
account, container, metadata, metadata_prefix, acceptable_statuses)
self.assertEquals(1, client.set_metadata_called)
self.assertEqual(1, client.set_metadata_called)
def test_delete_object(self):
class InternalClient(internal_client.InternalClient):
@ -910,18 +910,18 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals('DELETE', method)
self.test.assertEquals(self.path, path)
self.test.assertEquals({}, headers)
self.test.assertEquals((2, 404), acceptable_statuses)
self.test.assertEquals(None, body_file)
self.test.assertEqual('DELETE', method)
self.test.assertEqual(self.path, path)
self.test.assertEqual({}, headers)
self.test.assertEqual((2, 404), acceptable_statuses)
self.test.assertEqual(None, body_file)
account, container, obj = path_parts()
path = make_path(account, container, obj)
client = InternalClient(self, path)
client.delete_object(account, container, obj)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
def test_get_object_metadata(self):
account, container, obj = path_parts()
@ -933,8 +933,8 @@ class TestInternalClient(unittest.TestCase):
metadata = client.get_object_metadata(
account, container, obj, metadata_prefix,
acceptable_statuses)
self.assertEquals(client.metadata, metadata)
self.assertEquals(1, client.get_metadata_called)
self.assertEqual(client.metadata, metadata)
self.assertEqual(1, client.get_metadata_called)
def test_get_metadata_extra_headers(self):
class InternalClient(internal_client.InternalClient):
@ -994,7 +994,7 @@ class TestInternalClient(unittest.TestCase):
ret_lines = []
for line in client.iter_object_lines('account', 'container', 'object'):
ret_lines.append(line)
self.assertEquals(lines, ret_lines)
self.assertEqual(lines, ret_lines)
def test_iter_object_lines_compressed_object(self):
class InternalClient(internal_client.InternalClient):
@ -1015,7 +1015,7 @@ class TestInternalClient(unittest.TestCase):
for line in client.iter_object_lines(
'account', 'container', 'object.gz'):
ret_lines.append(line)
self.assertEquals(lines, ret_lines)
self.assertEqual(lines, ret_lines)
def test_iter_object_lines_404(self):
class InternalClient(internal_client.InternalClient):
@ -1034,7 +1034,7 @@ class TestInternalClient(unittest.TestCase):
'some_account', 'some_container', 'some_object',
acceptable_statuses=(2, 404)):
lines.append(line)
self.assertEquals([], lines)
self.assertEqual([], lines)
def test_set_object_metadata(self):
account, container, obj = path_parts()
@ -1047,7 +1047,7 @@ class TestInternalClient(unittest.TestCase):
client.set_object_metadata(
account, container, obj, metadata, metadata_prefix,
acceptable_statuses)
self.assertEquals(1, client.set_metadata_called)
self.assertEqual(1, client.set_metadata_called)
def test_upload_object(self):
class InternalClient(internal_client.InternalClient):
@ -1062,11 +1062,11 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals(self.path, path)
self.test.assertEqual(self.path, path)
exp_headers = dict(self.headers)
exp_headers['Transfer-Encoding'] = 'chunked'
self.test.assertEquals(exp_headers, headers)
self.test.assertEquals(self.fobj, fobj)
self.test.assertEqual(exp_headers, headers)
self.test.assertEqual(self.fobj, fobj)
fobj = 'some_fobj'
account, container, obj = path_parts()
@ -1075,7 +1075,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, path, headers, fobj)
client.upload_object(fobj, account, container, obj, headers)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
def test_upload_object_not_chunked(self):
class InternalClient(internal_client.InternalClient):
@ -1090,10 +1090,10 @@ class TestInternalClient(unittest.TestCase):
self, method, path, headers, acceptable_statuses,
body_file=None):
self.make_request_called += 1
self.test.assertEquals(self.path, path)
self.test.assertEqual(self.path, path)
exp_headers = dict(self.headers)
self.test.assertEquals(exp_headers, headers)
self.test.assertEquals(self.fobj, fobj)
self.test.assertEqual(exp_headers, headers)
self.test.assertEqual(self.fobj, fobj)
fobj = 'some_fobj'
account, container, obj = path_parts()
@ -1102,7 +1102,7 @@ class TestInternalClient(unittest.TestCase):
client = InternalClient(self, path, headers, fobj)
client.upload_object(fobj, account, container, obj, headers)
self.assertEquals(1, client.make_request_called)
self.assertEqual(1, client.make_request_called)
class TestGetAuth(unittest.TestCase):

File diff suppressed because it is too large Load Diff

View File

@ -191,20 +191,20 @@ class TestMemcached(unittest.TestCase):
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
memcache_client.set('some_key', [1, 2, 3])
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEquals(mock.cache.values()[0][1], '0')
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(mock.cache.values()[0][1], '0')
memcache_client.set('some_key', [4, 5, 6])
self.assertEquals(memcache_client.get('some_key'), [4, 5, 6])
self.assertEqual(memcache_client.get('some_key'), [4, 5, 6])
memcache_client.set('some_key', ['simple str', 'utf8 str éà'])
# As per http://wiki.openstack.org/encoding,
# we should expect to have unicode
self.assertEquals(
self.assertEqual(
memcache_client.get('some_key'), ['simple str', u'utf8 str éà'])
self.assertTrue(float(mock.cache.values()[0][1]) == 0)
memcache_client.set('some_key', [1, 2, 3], timeout=10)
self.assertEquals(mock.cache.values()[0][1], '10')
self.assertEqual(mock.cache.values()[0][1], '10')
memcache_client.set('some_key', [1, 2, 3], time=20)
self.assertEquals(mock.cache.values()[0][1], '20')
self.assertEqual(mock.cache.values()[0][1], '20')
sixtydays = 60 * 24 * 60 * 60
esttimeout = time.time() + sixtydays
@ -220,16 +220,16 @@ class TestMemcached(unittest.TestCase):
mock = MockMemcached()
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
self.assertEquals(memcache_client.incr('some_key', delta=5), 5)
self.assertEquals(memcache_client.get('some_key'), '5')
self.assertEquals(memcache_client.incr('some_key', delta=5), 10)
self.assertEquals(memcache_client.get('some_key'), '10')
self.assertEquals(memcache_client.incr('some_key', delta=1), 11)
self.assertEquals(memcache_client.get('some_key'), '11')
self.assertEquals(memcache_client.incr('some_key', delta=-5), 6)
self.assertEquals(memcache_client.get('some_key'), '6')
self.assertEquals(memcache_client.incr('some_key', delta=-15), 0)
self.assertEquals(memcache_client.get('some_key'), '0')
self.assertEqual(memcache_client.incr('some_key', delta=5), 5)
self.assertEqual(memcache_client.get('some_key'), '5')
self.assertEqual(memcache_client.incr('some_key', delta=5), 10)
self.assertEqual(memcache_client.get('some_key'), '10')
self.assertEqual(memcache_client.incr('some_key', delta=1), 11)
self.assertEqual(memcache_client.get('some_key'), '11')
self.assertEqual(memcache_client.incr('some_key', delta=-5), 6)
self.assertEqual(memcache_client.get('some_key'), '6')
self.assertEqual(memcache_client.incr('some_key', delta=-15), 0)
self.assertEqual(memcache_client.get('some_key'), '0')
mock.read_return_none = True
self.assertRaises(memcached.MemcacheConnectionError,
memcache_client.incr, 'some_key', delta=-15)
@ -241,38 +241,38 @@ class TestMemcached(unittest.TestCase):
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
memcache_client.incr('some_key', delta=5, time=55)
self.assertEquals(memcache_client.get('some_key'), '5')
self.assertEquals(mock.cache.values()[0][1], '55')
self.assertEqual(memcache_client.get('some_key'), '5')
self.assertEqual(mock.cache.values()[0][1], '55')
memcache_client.delete('some_key')
self.assertEquals(memcache_client.get('some_key'), None)
self.assertEqual(memcache_client.get('some_key'), None)
fiftydays = 50 * 24 * 60 * 60
esttimeout = time.time() + fiftydays
memcache_client.incr('some_key', delta=5, time=fiftydays)
self.assertEquals(memcache_client.get('some_key'), '5')
self.assertEqual(memcache_client.get('some_key'), '5')
self.assertTrue(
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
memcache_client.delete('some_key')
self.assertEquals(memcache_client.get('some_key'), None)
self.assertEqual(memcache_client.get('some_key'), None)
memcache_client.incr('some_key', delta=5)
self.assertEquals(memcache_client.get('some_key'), '5')
self.assertEquals(mock.cache.values()[0][1], '0')
self.assertEqual(memcache_client.get('some_key'), '5')
self.assertEqual(mock.cache.values()[0][1], '0')
memcache_client.incr('some_key', delta=5, time=55)
self.assertEquals(memcache_client.get('some_key'), '10')
self.assertEquals(mock.cache.values()[0][1], '0')
self.assertEqual(memcache_client.get('some_key'), '10')
self.assertEqual(mock.cache.values()[0][1], '0')
def test_decr(self):
memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'])
mock = MockMemcached()
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
self.assertEquals(memcache_client.decr('some_key', delta=5), 0)
self.assertEquals(memcache_client.get('some_key'), '0')
self.assertEquals(memcache_client.incr('some_key', delta=15), 15)
self.assertEquals(memcache_client.get('some_key'), '15')
self.assertEquals(memcache_client.decr('some_key', delta=4), 11)
self.assertEquals(memcache_client.get('some_key'), '11')
self.assertEquals(memcache_client.decr('some_key', delta=15), 0)
self.assertEquals(memcache_client.get('some_key'), '0')
self.assertEqual(memcache_client.decr('some_key', delta=5), 0)
self.assertEqual(memcache_client.get('some_key'), '0')
self.assertEqual(memcache_client.incr('some_key', delta=15), 15)
self.assertEqual(memcache_client.get('some_key'), '15')
self.assertEqual(memcache_client.decr('some_key', delta=4), 11)
self.assertEqual(memcache_client.get('some_key'), '11')
self.assertEqual(memcache_client.decr('some_key', delta=15), 0)
self.assertEqual(memcache_client.get('some_key'), '0')
mock.read_return_none = True
self.assertRaises(memcached.MemcacheConnectionError,
memcache_client.decr, 'some_key', delta=15)
@ -288,8 +288,8 @@ class TestMemcached(unittest.TestCase):
memcache_client._client_cache['1.2.3.5:11211'] = MockedMemcachePool(
[(mock1, mock1)])
memcache_client.set('some_key', [1, 2, 3])
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEquals(mock1.exploded, True)
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(mock1.exploded, True)
def test_delete(self):
memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'])
@ -297,9 +297,9 @@ class TestMemcached(unittest.TestCase):
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
memcache_client.set('some_key', [1, 2, 3])
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
memcache_client.delete('some_key')
self.assertEquals(memcache_client.get('some_key'), None)
self.assertEqual(memcache_client.get('some_key'), None)
def test_multi(self):
memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'])
@ -308,21 +308,21 @@ class TestMemcached(unittest.TestCase):
[(mock, mock)] * 2)
memcache_client.set_multi(
{'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key')
self.assertEquals(
self.assertEqual(
memcache_client.get_multi(('some_key2', 'some_key1'), 'multi_key'),
[[4, 5, 6], [1, 2, 3]])
self.assertEquals(mock.cache.values()[0][1], '0')
self.assertEquals(mock.cache.values()[1][1], '0')
self.assertEqual(mock.cache.values()[0][1], '0')
self.assertEqual(mock.cache.values()[1][1], '0')
memcache_client.set_multi(
{'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key',
timeout=10)
self.assertEquals(mock.cache.values()[0][1], '10')
self.assertEquals(mock.cache.values()[1][1], '10')
self.assertEqual(mock.cache.values()[0][1], '10')
self.assertEqual(mock.cache.values()[1][1], '10')
memcache_client.set_multi(
{'some_key1': [1, 2, 3], 'some_key2': [4, 5, 6]}, 'multi_key',
time=20)
self.assertEquals(mock.cache.values()[0][1], '20')
self.assertEquals(mock.cache.values()[1][1], '20')
self.assertEqual(mock.cache.values()[0][1], '20')
self.assertEqual(mock.cache.values()[1][1], '20')
fortydays = 50 * 24 * 60 * 60
esttimeout = time.time() + fortydays
@ -333,7 +333,7 @@ class TestMemcached(unittest.TestCase):
-1 <= float(mock.cache.values()[0][1]) - esttimeout <= 1)
self.assertTrue(
-1 <= float(mock.cache.values()[1][1]) - esttimeout <= 1)
self.assertEquals(memcache_client.get_multi(
self.assertEqual(memcache_client.get_multi(
('some_key2', 'some_key1', 'not_exists'), 'multi_key'),
[[4, 5, 6], [1, 2, 3], None])
@ -344,18 +344,18 @@ class TestMemcached(unittest.TestCase):
memcache_client._client_cache['1.2.3.4:11211'] = MockedMemcachePool(
[(mock, mock)] * 2)
memcache_client.set('some_key', [1, 2, 3])
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
memcache_client._allow_pickle = False
memcache_client._allow_unpickle = True
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
memcache_client._allow_unpickle = False
self.assertEquals(memcache_client.get('some_key'), None)
self.assertEqual(memcache_client.get('some_key'), None)
memcache_client.set('some_key', [1, 2, 3])
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
memcache_client._allow_unpickle = True
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
memcache_client._allow_pickle = True
self.assertEquals(memcache_client.get('some_key'), [1, 2, 3])
self.assertEqual(memcache_client.get('some_key'), [1, 2, 3])
def test_connection_pooling(self):
with patch('swift.common.memcached.socket') as mock_module:
@ -379,7 +379,7 @@ class TestMemcached(unittest.TestCase):
memcache_client = memcached.MemcacheRing(['1.2.3.4:11211'],
connect_timeout=10)
# sanity
self.assertEquals(1, len(memcache_client._client_cache))
self.assertEqual(1, len(memcache_client._client_cache))
for server, pool in memcache_client._client_cache.items():
self.assertEqual(2, pool.max_size)

View File

@ -56,13 +56,13 @@ class TestRequestHelpers(unittest.TestCase):
def test_strip_sys_meta_prefix(self):
mt = 'sysmeta'
for st in server_types:
self.assertEquals(strip_sys_meta_prefix(st, 'x-%s-%s-a'
self.assertEqual(strip_sys_meta_prefix(st, 'x-%s-%s-a'
% (st, mt)), 'a')
def test_strip_user_meta_prefix(self):
mt = 'meta'
for st in server_types:
self.assertEquals(strip_user_meta_prefix(st, 'x-%s-%s-a'
self.assertEqual(strip_user_meta_prefix(st, 'x-%s-%s-a'
% (st, mt)), 'a')
def test_remove_items(self):
@ -70,8 +70,8 @@ class TestRequestHelpers(unittest.TestCase):
'c': 'd'}
test = lambda x: x == 'a'
rem = remove_items(src, test)
self.assertEquals(src, {'c': 'd'})
self.assertEquals(rem, {'a': 'b'})
self.assertEqual(src, {'c': 'd'})
self.assertEqual(rem, {'a': 'b'})
def test_copy_header_subset(self):
src = {'a': 'b',

View File

@ -104,7 +104,7 @@ class TestSplice(unittest.TestCase):
self.assertEqual(res, (3, 6, None))
self.assertEqual(os.lseek(fd.fileno(), 0, os.SEEK_CUR), 0)
self.assertEquals(os.read(pa, 6), 'abcdef')
self.assertEqual(os.read(pa, 6), 'abcdef')
def test_splice_pipe_to_file(self):
'''Test `splice` from a pipe to a file'''

View File

@ -80,15 +80,15 @@ class TestStoragePolicies(unittest.TestCase):
{'name': 'one'},
{'name': 'ten'}]
swift_info = POLICIES.get_policy_info()
self.assertEquals(sorted(expect, key=lambda k: k['name']),
self.assertEqual(sorted(expect, key=lambda k: k['name']),
sorted(swift_info, key=lambda k: k['name']))
@patch_policies
def test_get_policy_string(self):
self.assertEquals(get_policy_string('something', 0), 'something')
self.assertEquals(get_policy_string('something', None), 'something')
self.assertEquals(get_policy_string('something', ''), 'something')
self.assertEquals(get_policy_string('something', 1),
self.assertEqual(get_policy_string('something', 0), 'something')
self.assertEqual(get_policy_string('something', None), 'something')
self.assertEqual(get_policy_string('something', ''), 'something')
self.assertEqual(get_policy_string('something', 1),
'something' + '-1')
self.assertRaises(PolicyError, get_policy_string, 'something', 99)
@ -177,16 +177,16 @@ class TestStoragePolicies(unittest.TestCase):
StoragePolicy(1, 'one', False),
StoragePolicy(2, 'two', False)]
policies = StoragePolicyCollection(test_policies)
self.assertEquals(policies.default, test_policies[0])
self.assertEquals(policies.default.name, 'zero')
self.assertEqual(policies.default, test_policies[0])
self.assertEqual(policies.default.name, 'zero')
# non-zero explicit default
test_policies = [StoragePolicy(0, 'zero', False),
StoragePolicy(1, 'one', False),
StoragePolicy(2, 'two', True)]
policies = StoragePolicyCollection(test_policies)
self.assertEquals(policies.default, test_policies[2])
self.assertEquals(policies.default.name, 'two')
self.assertEqual(policies.default, test_policies[2])
self.assertEqual(policies.default.name, 'two')
# multiple defaults
test_policies = [StoragePolicy(0, 'zero', False),
@ -199,8 +199,8 @@ class TestStoragePolicies(unittest.TestCase):
# nothing specified
test_policies = []
policies = StoragePolicyCollection(test_policies)
self.assertEquals(policies.default, policies[0])
self.assertEquals(policies.default.name, 'Policy-0')
self.assertEqual(policies.default, policies[0])
self.assertEqual(policies.default.name, 'Policy-0')
# no default specified with only policy index 0
test_policies = [StoragePolicy(0, 'zero')]
@ -221,9 +221,9 @@ class TestStoragePolicies(unittest.TestCase):
StoragePolicy(1, 'one', False),
StoragePolicy(2, 'two', False, is_deprecated=True)]
policies = StoragePolicyCollection(test_policies)
self.assertEquals(policies.default, test_policies[0])
self.assertEquals(policies.default.name, 'zero')
self.assertEquals(len(policies), 3)
self.assertEqual(policies.default, test_policies[0])
self.assertEqual(policies.default.name, 'zero')
self.assertEqual(len(policies), 3)
# multiple policies requires default
test_policies = [StoragePolicy(0, 'zero', False),
@ -280,7 +280,7 @@ class TestStoragePolicies(unittest.TestCase):
# no type specified - make sure the policy is initialized to
# DEFAULT_POLICY_TYPE
test_policy = FakeStoragePolicy(0, 'zero', True)
self.assertEquals(test_policy.policy_type, 'fake')
self.assertEqual(test_policy.policy_type, 'fake')
def test_validate_policies_type_invalid(self):
class BogusStoragePolicy(FakeStoragePolicy):
@ -299,15 +299,15 @@ class TestStoragePolicies(unittest.TestCase):
ec_ndata=10, ec_nparity=3),
]
policies = StoragePolicyCollection(test_policies)
self.assertEquals(policies.get_by_index(0).policy_type,
self.assertEqual(policies.get_by_index(0).policy_type,
REPL_POLICY)
self.assertEquals(policies.get_by_index(1).policy_type,
self.assertEqual(policies.get_by_index(1).policy_type,
REPL_POLICY)
self.assertEquals(policies.get_by_index(2).policy_type,
self.assertEqual(policies.get_by_index(2).policy_type,
REPL_POLICY)
self.assertEquals(policies.get_by_index(3).policy_type,
self.assertEqual(policies.get_by_index(3).policy_type,
REPL_POLICY)
self.assertEquals(policies.get_by_index(10).policy_type,
self.assertEqual(policies.get_by_index(10).policy_type,
EC_POLICY)
def test_names_are_normalized(self):
@ -650,24 +650,24 @@ class TestStoragePolicies(unittest.TestCase):
""")
policies = parse_storage_policies(conf)
self.assertEquals(True, policies.get_by_index(5).is_default)
self.assertEquals(False, policies.get_by_index(0).is_default)
self.assertEquals(False, policies.get_by_index(6).is_default)
self.assertEqual(True, policies.get_by_index(5).is_default)
self.assertEqual(False, policies.get_by_index(0).is_default)
self.assertEqual(False, policies.get_by_index(6).is_default)
self.assertEquals("object", policies.get_by_name("zero").ring_name)
self.assertEquals("object-5", policies.get_by_name("one").ring_name)
self.assertEquals("object-6", policies.get_by_name("apple").ring_name)
self.assertEqual("object", policies.get_by_name("zero").ring_name)
self.assertEqual("object-5", policies.get_by_name("one").ring_name)
self.assertEqual("object-6", policies.get_by_name("apple").ring_name)
self.assertEqual(0, int(policies.get_by_name('zero')))
self.assertEqual(5, int(policies.get_by_name('one')))
self.assertEqual(6, int(policies.get_by_name('apple')))
self.assertEquals("zero", policies.get_by_index(0).name)
self.assertEquals("zero", policies.get_by_index("0").name)
self.assertEquals("one", policies.get_by_index(5).name)
self.assertEquals("apple", policies.get_by_index(6).name)
self.assertEquals("zero", policies.get_by_index(None).name)
self.assertEquals("zero", policies.get_by_index('').name)
self.assertEqual("zero", policies.get_by_index(0).name)
self.assertEqual("zero", policies.get_by_index("0").name)
self.assertEqual("one", policies.get_by_index(5).name)
self.assertEqual("apple", policies.get_by_index(6).name)
self.assertEqual("zero", policies.get_by_index(None).name)
self.assertEqual("zero", policies.get_by_index('').name)
self.assertEqual(policies.get_by_index(0), policies.legacy)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -73,41 +73,41 @@ class TestWSGI(unittest.TestCase):
def test_monkey_patch_mimetools(self):
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).type, 'text/plain')
self.assertEqual(mimetools.Message(sio).type, 'text/plain')
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).plisttext, '')
self.assertEqual(mimetools.Message(sio).plisttext, '')
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).maintype, 'text')
self.assertEqual(mimetools.Message(sio).maintype, 'text')
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).subtype, 'plain')
self.assertEqual(mimetools.Message(sio).subtype, 'plain')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).type, 'text/html')
self.assertEqual(mimetools.Message(sio).type, 'text/html')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).plisttext,
self.assertEqual(mimetools.Message(sio).plisttext,
'; charset=ISO-8859-4')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).maintype, 'text')
self.assertEqual(mimetools.Message(sio).maintype, 'text')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).subtype, 'html')
self.assertEqual(mimetools.Message(sio).subtype, 'html')
wsgi.monkey_patch_mimetools()
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).type, None)
self.assertEqual(mimetools.Message(sio).type, None)
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).plisttext, '')
self.assertEqual(mimetools.Message(sio).plisttext, '')
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).maintype, None)
self.assertEqual(mimetools.Message(sio).maintype, None)
sio = StringIO('blah')
self.assertEquals(mimetools.Message(sio).subtype, None)
self.assertEqual(mimetools.Message(sio).subtype, None)
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).type, 'text/html')
self.assertEqual(mimetools.Message(sio).type, 'text/html')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).plisttext,
self.assertEqual(mimetools.Message(sio).plisttext,
'; charset=ISO-8859-4')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).maintype, 'text')
self.assertEqual(mimetools.Message(sio).maintype, 'text')
sio = StringIO('Content-Type: text/html; charset=ISO-8859-4')
self.assertEquals(mimetools.Message(sio).subtype, 'html')
self.assertEqual(mimetools.Message(sio).subtype, 'html')
def test_init_request_processor(self):
config = """
@ -150,7 +150,7 @@ class TestWSGI(unittest.TestCase):
expected = swift.proxy.server.Application
self.assertTrue(isinstance(app, expected))
# config settings applied to app instance
self.assertEquals(0.2, app.conn_timeout)
self.assertEqual(0.2, app.conn_timeout)
# appconfig returns values from 'proxy-server' section
expected = {
'__file__': conf_file,
@ -158,10 +158,10 @@ class TestWSGI(unittest.TestCase):
'conn_timeout': '0.2',
'swift_dir': t,
}
self.assertEquals(expected, conf)
self.assertEqual(expected, conf)
# logger works
logger.info('testing')
self.assertEquals('proxy-server', log_name)
self.assertEqual('proxy-server', log_name)
@with_tempdir
def test_loadapp_from_file(self, tempdir):
@ -215,7 +215,7 @@ class TestWSGI(unittest.TestCase):
self.assertTrue(isinstance(app, expected))
self.assertTrue(isinstance(app.app, swift.proxy.server.Application))
# config settings applied to app instance
self.assertEquals(0.2, app.app.conn_timeout)
self.assertEqual(0.2, app.app.conn_timeout)
# appconfig returns values from 'proxy-server' section
expected = {
'__file__': conf_dir,
@ -223,10 +223,10 @@ class TestWSGI(unittest.TestCase):
'conn_timeout': '0.2',
'swift_dir': conf_root,
}
self.assertEquals(expected, conf)
self.assertEqual(expected, conf)
# logger works
logger.info('testing')
self.assertEquals('proxy-server', log_name)
self.assertEqual('proxy-server', log_name)
def test_get_socket_bad_values(self):
# first try with no port set
@ -287,14 +287,14 @@ class TestWSGI(unittest.TestCase):
if hasattr(socket, 'TCP_KEEPIDLE'):
expected_socket_opts[socket.IPPROTO_TCP][
socket.TCP_KEEPIDLE] = 600
self.assertEquals(sock.opts, expected_socket_opts)
self.assertEqual(sock.opts, expected_socket_opts)
# test ssl
sock = wsgi.get_socket(ssl_conf)
expected_kwargs = {
'certfile': '',
'keyfile': '',
}
self.assertEquals(wsgi.ssl.wrap_socket_called, [expected_kwargs])
self.assertEqual(wsgi.ssl.wrap_socket_called, [expected_kwargs])
finally:
wsgi.listen = old_listen
wsgi.ssl = old_ssl
@ -375,9 +375,9 @@ class TestWSGI(unittest.TestCase):
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assertEquals('HTTP/1.0',
self.assertEqual('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
self.assertEqual(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
@ -385,12 +385,12 @@ class TestWSGI(unittest.TestCase):
self.assertTrue(_wsgi.server.called)
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assertEqual(sock, server_sock)
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assertEqual(20, server_app.client_timeout)
self.assertTrue(isinstance(server_logger, wsgi.NullLogger))
self.assertTrue('custom_pool' in kwargs)
self.assertEquals(1000, kwargs['custom_pool'].size)
self.assertEqual(1000, kwargs['custom_pool'].size)
def test_run_server_with_latest_eventlet(self):
config = """
@ -427,7 +427,7 @@ class TestWSGI(unittest.TestCase):
self.assertTrue(_wsgi.server.called)
args, kwargs = _wsgi.server.call_args
self.assertEquals(kwargs.get('capitalize_response_headers'), False)
self.assertEqual(kwargs.get('capitalize_response_headers'), False)
def test_run_server_conf_dir(self):
config_dir = {
@ -463,9 +463,9 @@ class TestWSGI(unittest.TestCase):
wsgi.run_server(conf, logger, sock)
self.assertTrue(os.environ['TZ'] is not '')
self.assertEquals('HTTP/1.0',
self.assertEqual('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
self.assertEqual(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
@ -473,7 +473,7 @@ class TestWSGI(unittest.TestCase):
self.assertTrue(_wsgi.server.called)
args, kwargs = _wsgi.server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assertEqual(sock, server_sock)
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertTrue(isinstance(server_logger, wsgi.NullLogger))
self.assertTrue('custom_pool' in kwargs)
@ -514,9 +514,9 @@ class TestWSGI(unittest.TestCase):
logger = logging.getLogger('test')
sock = listen(('localhost', 0))
wsgi.run_server(conf, logger, sock)
self.assertEquals('HTTP/1.0',
self.assertEqual('HTTP/1.0',
_wsgi.HttpProtocol.default_request_version)
self.assertEquals(30, _wsgi.WRITE_TIMEOUT)
self.assertEqual(30, _wsgi.WRITE_TIMEOUT)
_eventlet.hubs.use_hub.assert_called_with(utils.get_hub())
_eventlet.patcher.monkey_patch.assert_called_with(all=False,
socket=True)
@ -524,12 +524,12 @@ class TestWSGI(unittest.TestCase):
self.assertTrue(mock_server.called)
args, kwargs = mock_server.call_args
server_sock, server_app, server_logger = args
self.assertEquals(sock, server_sock)
self.assertEqual(sock, server_sock)
self.assertTrue(isinstance(server_app, swift.proxy.server.Application))
self.assertEquals(20, server_app.client_timeout)
self.assertEqual(20, server_app.client_timeout)
self.assertEqual(server_logger, None)
self.assertTrue('custom_pool' in kwargs)
self.assertEquals(1000, kwargs['custom_pool'].size)
self.assertEqual(1000, kwargs['custom_pool'].size)
def test_appconfig_dir_ignores_hidden_files(self):
config_dir = {
@ -554,26 +554,26 @@ class TestWSGI(unittest.TestCase):
'here': os.path.join(path, 'server.conf.d'),
'port': '8080',
}
self.assertEquals(conf, expected)
self.assertEqual(conf, expected)
def test_pre_auth_wsgi_input(self):
oldenv = {}
newenv = wsgi.make_pre_authed_env(oldenv)
self.assertTrue('wsgi.input' in newenv)
self.assertEquals(newenv['wsgi.input'].read(), '')
self.assertEqual(newenv['wsgi.input'].read(), '')
oldenv = {'wsgi.input': BytesIO(b'original wsgi.input')}
newenv = wsgi.make_pre_authed_env(oldenv)
self.assertTrue('wsgi.input' in newenv)
self.assertEquals(newenv['wsgi.input'].read(), '')
self.assertEqual(newenv['wsgi.input'].read(), '')
oldenv = {'swift.source': 'UT'}
newenv = wsgi.make_pre_authed_env(oldenv)
self.assertEquals(newenv['swift.source'], 'UT')
self.assertEqual(newenv['swift.source'], 'UT')
oldenv = {'swift.source': 'UT'}
newenv = wsgi.make_pre_authed_env(oldenv, swift_source='SA')
self.assertEquals(newenv['swift.source'], 'SA')
self.assertEqual(newenv['swift.source'], 'SA')
def test_pre_auth_req(self):
class FakeReq(object):
@ -583,7 +583,7 @@ class TestWSGI(unittest.TestCase):
environ = {}
if headers is None:
headers = {}
self.assertEquals(environ['swift.authorize']('test'), None)
self.assertEqual(environ['swift.authorize']('test'), None)
self.assertFalse('HTTP_X_TRANS_ID' in environ)
was_blank = Request.blank
Request.blank = FakeReq.fake_blank
@ -597,23 +597,23 @@ class TestWSGI(unittest.TestCase):
r = wsgi.make_pre_authed_request(
{'HTTP_X_TRANS_ID': '1234'}, 'PUT', path=quote('/a space'),
body='tester', headers={})
self.assertEquals(r.path, quote('/a space'))
self.assertEqual(r.path, quote('/a space'))
def test_pre_auth_req_drops_query(self):
r = wsgi.make_pre_authed_request(
{'QUERY_STRING': 'original'}, 'GET', 'path')
self.assertEquals(r.query_string, 'original')
self.assertEqual(r.query_string, 'original')
r = wsgi.make_pre_authed_request(
{'QUERY_STRING': 'original'}, 'GET', 'path?replacement')
self.assertEquals(r.query_string, 'replacement')
self.assertEqual(r.query_string, 'replacement')
r = wsgi.make_pre_authed_request(
{'QUERY_STRING': 'original'}, 'GET', 'path?')
self.assertEquals(r.query_string, '')
self.assertEqual(r.query_string, '')
def test_pre_auth_req_with_body(self):
r = wsgi.make_pre_authed_request(
{'QUERY_STRING': 'original'}, 'GET', 'path', 'the body')
self.assertEquals(r.body, 'the body')
self.assertEqual(r.body, 'the body')
def test_pre_auth_creates_script_name(self):
e = wsgi.make_pre_authed_env({})
@ -621,20 +621,20 @@ class TestWSGI(unittest.TestCase):
def test_pre_auth_copies_script_name(self):
e = wsgi.make_pre_authed_env({'SCRIPT_NAME': '/script_name'})
self.assertEquals(e['SCRIPT_NAME'], '/script_name')
self.assertEqual(e['SCRIPT_NAME'], '/script_name')
def test_pre_auth_copies_script_name_unless_path_overridden(self):
e = wsgi.make_pre_authed_env({'SCRIPT_NAME': '/script_name'},
path='/override')
self.assertEquals(e['SCRIPT_NAME'], '')
self.assertEquals(e['PATH_INFO'], '/override')
self.assertEqual(e['SCRIPT_NAME'], '')
self.assertEqual(e['PATH_INFO'], '/override')
def test_pre_auth_req_swift_source(self):
r = wsgi.make_pre_authed_request(
{'QUERY_STRING': 'original'}, 'GET', 'path', 'the body',
swift_source='UT')
self.assertEquals(r.body, 'the body')
self.assertEquals(r.environ['swift.source'], 'UT')
self.assertEqual(r.body, 'the body')
self.assertEqual(r.environ['swift.source'], 'UT')
def test_run_server_global_conf_callback(self):
calls = defaultdict(lambda: 0)
@ -779,52 +779,52 @@ class TestWSGI(unittest.TestCase):
def test_pre_auth_req_with_empty_env_no_path(self):
r = wsgi.make_pre_authed_request(
{}, 'GET')
self.assertEquals(r.path, quote(''))
self.assertEqual(r.path, quote(''))
self.assertTrue('SCRIPT_NAME' in r.environ)
self.assertTrue('PATH_INFO' in r.environ)
def test_pre_auth_req_with_env_path(self):
r = wsgi.make_pre_authed_request(
{'PATH_INFO': '/unquoted path with %20'}, 'GET')
self.assertEquals(r.path, quote('/unquoted path with %20'))
self.assertEquals(r.environ['SCRIPT_NAME'], '')
self.assertEqual(r.path, quote('/unquoted path with %20'))
self.assertEqual(r.environ['SCRIPT_NAME'], '')
def test_pre_auth_req_with_env_script(self):
r = wsgi.make_pre_authed_request({'SCRIPT_NAME': '/hello'}, 'GET')
self.assertEquals(r.path, quote('/hello'))
self.assertEqual(r.path, quote('/hello'))
def test_pre_auth_req_with_env_path_and_script(self):
env = {'PATH_INFO': '/unquoted path with %20',
'SCRIPT_NAME': '/script'}
r = wsgi.make_pre_authed_request(env, 'GET')
expected_path = quote(env['SCRIPT_NAME'] + env['PATH_INFO'])
self.assertEquals(r.path, expected_path)
self.assertEqual(r.path, expected_path)
env = {'PATH_INFO': '', 'SCRIPT_NAME': '/script'}
r = wsgi.make_pre_authed_request(env, 'GET')
self.assertEquals(r.path, '/script')
self.assertEqual(r.path, '/script')
env = {'PATH_INFO': '/path', 'SCRIPT_NAME': ''}
r = wsgi.make_pre_authed_request(env, 'GET')
self.assertEquals(r.path, '/path')
self.assertEqual(r.path, '/path')
env = {'PATH_INFO': '', 'SCRIPT_NAME': ''}
r = wsgi.make_pre_authed_request(env, 'GET')
self.assertEquals(r.path, '')
self.assertEqual(r.path, '')
def test_pre_auth_req_path_overrides_env(self):
env = {'PATH_INFO': '/path', 'SCRIPT_NAME': '/script'}
r = wsgi.make_pre_authed_request(env, 'GET', '/override')
self.assertEquals(r.path, '/override')
self.assertEquals(r.environ['SCRIPT_NAME'], '')
self.assertEquals(r.environ['PATH_INFO'], '/override')
self.assertEqual(r.path, '/override')
self.assertEqual(r.environ['SCRIPT_NAME'], '')
self.assertEqual(r.environ['PATH_INFO'], '/override')
def test_make_env_keep_user_project_id(self):
oldenv = {'HTTP_X_USER_ID': '1234', 'HTTP_X_PROJECT_ID': '5678'}
newenv = wsgi.make_env(oldenv)
self.assertTrue('HTTP_X_USER_ID' in newenv)
self.assertEquals(newenv['HTTP_X_USER_ID'], '1234')
self.assertEqual(newenv['HTTP_X_USER_ID'], '1234')
self.assertTrue('HTTP_X_PROJECT_ID' in newenv)
self.assertEquals(newenv['HTTP_X_PROJECT_ID'], '5678')
self.assertEqual(newenv['HTTP_X_PROJECT_ID'], '5678')
class TestServersPerPortStrategy(unittest.TestCase):
@ -1214,12 +1214,12 @@ class TestWSGIContext(unittest.TestCase):
wc = wsgi.WSGIContext(app)
r = Request.blank('/')
it = wc._app_call(r.environ)
self.assertEquals(wc._response_status, '200 Ok')
self.assertEquals(''.join(it), 'Ok\n')
self.assertEqual(wc._response_status, '200 Ok')
self.assertEqual(''.join(it), 'Ok\n')
r = Request.blank('/')
it = wc._app_call(r.environ)
self.assertEquals(wc._response_status, '404 Not Found')
self.assertEquals(''.join(it), 'Ok\n')
self.assertEqual(wc._response_status, '404 Not Found')
self.assertEqual(''.join(it), 'Ok\n')
def test_app_iter_is_closable(self):
@ -1234,7 +1234,7 @@ class TestWSGIContext(unittest.TestCase):
wc = wsgi.WSGIContext(app)
r = Request.blank('/')
iterable = wc._app_call(r.environ)
self.assertEquals(wc._response_status, '200 OK')
self.assertEqual(wc._response_status, '200 OK')
iterator = iter(iterable)
self.assertEqual('aaaaa', next(iterator))

View File

@ -825,7 +825,7 @@ class TestContainerController(unittest.TestCase):
resp = req.get_response(self.controller)
self.assertEqual(resp.status_int, 204)
self.assertTrue('x-container-meta-test' not in resp.headers)
self.assertEquals(resp.headers.get('x-put-timestamp'),
self.assertEqual(resp.headers.get('x-put-timestamp'),
'0000000004.00000')
def test_POST_HEAD_sys_metadata(self):

View File

@ -767,7 +767,7 @@ class TestObjectReplicator(unittest.TestCase):
(0, '/sda/3'): 2,
(1, '/sda/3'): 2,
}
self.assertEquals(dict(found_replicate_calls),
self.assertEqual(dict(found_replicate_calls),
expected_replicate_calls)
def test_replicator_skips_bogus_partition_dirs(self):

View File

@ -2079,11 +2079,11 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase):
with set_http_connect(*status_codes, body_iter=body_iter,
headers=headers):
resp = req.get_response(self.app)
self.assertEquals(resp.status_int, 200)
self.assertEquals(resp.body, '')
self.assertEqual(resp.status_int, 200)
self.assertEqual(resp.body, '')
# 200OK shows original object content length
self.assertEquals(resp.headers['Content-Length'], '10')
self.assertEquals(resp.headers['Etag'], 'foo')
self.assertEqual(resp.headers['Content-Length'], '10')
self.assertEqual(resp.headers['Etag'], 'foo')
# not found HEAD
responses = [(404, '', {})] * self.replicas() * 2
@ -2092,9 +2092,9 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase):
with set_http_connect(*status_codes, body_iter=body_iter,
headers=headers):
resp = req.get_response(self.app)
self.assertEquals(resp.status_int, 404)
self.assertEqual(resp.status_int, 404)
# 404 shows actual response body size (i.e. 0 for HEAD)
self.assertEquals(resp.headers['Content-Length'], '0')
self.assertEqual(resp.headers['Content-Length'], '0')
def test_PUT_with_slow_commits(self):
# It's important that this timeout be much less than the delay in
@ -2248,9 +2248,9 @@ class TestECObjController(BaseObjectControllerMixin, unittest.TestCase):
with set_http_connect(*status_codes, body_iter=body_iter,
headers=headers, expect_headers=expect_headers):
resp = req.get_response(self.app)
self.assertEquals(resp.status_int, 416)
self.assertEquals(resp.content_length, len(range_not_satisfiable_body))
self.assertEquals(resp.body, range_not_satisfiable_body)
self.assertEqual(resp.status_int, 416)
self.assertEqual(resp.content_length, len(range_not_satisfiable_body))
self.assertEqual(resp.body, range_not_satisfiable_body)
if __name__ == '__main__':

View File

@ -2218,8 +2218,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(gotten_obj, obj)
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
@unpatch_policies
def test_conditional_GET_ec(self):
@ -2294,8 +2294,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(resp.status_int, 304)
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
@unpatch_policies
def test_GET_ec_big(self):
@ -2353,8 +2353,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(gotten_obj, obj)
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
@unpatch_policies
def test_GET_ec_failure_handling(self):
@ -2473,8 +2473,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual('chartreuse', headers['X-Object-Meta-Color'])
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
@unpatch_policies
def test_GET_ec_404(self):
@ -2495,8 +2495,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(headers[:len(exp)], exp)
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
@unpatch_policies
def test_HEAD_ec_404(self):
@ -2517,8 +2517,8 @@ class TestObjectController(unittest.TestCase):
self.assertEqual(headers[:len(exp)], exp)
error_lines = prosrv.logger.get_lines_for_level('error')
warn_lines = prosrv.logger.get_lines_for_level('warning')
self.assertEquals(len(error_lines), 0) # sanity
self.assertEquals(len(warn_lines), 0) # sanity
self.assertEqual(len(error_lines), 0) # sanity
self.assertEqual(len(warn_lines), 0) # sanity
def test_PUT_expect_header_zero_content_length(self):
test_errors = []