change assert(Not)Equals to assert(Not)Equal
According to http://docs.python.org/2/library/unittest.html assert(Not)Equals is a deprecated alias of assert(Not)Equal. Change-Id: I75845cb9b71bcbaec76e12492b38260e09a2df13 Closes-Bug: #1329757
This commit is contained in:
parent
73672a47a4
commit
48a4c8b493
@ -134,7 +134,7 @@ class TestSwiftOnFile(Base):
|
|||||||
file_name), 'r')
|
file_name), 'r')
|
||||||
data_read_from_mountP = fhOnMountPoint.read()
|
data_read_from_mountP = fhOnMountPoint.read()
|
||||||
md5_returned = hashlib.md5(data_read_from_mountP).hexdigest()
|
md5_returned = hashlib.md5(data_read_from_mountP).hexdigest()
|
||||||
self.assertEquals(md5_returned, file_info['etag'])
|
self.assertEqual(md5_returned, file_info['etag'])
|
||||||
fhOnMountPoint.close()
|
fhOnMountPoint.close()
|
||||||
|
|
||||||
def test_GET_on_file_created_over_mountpoint(self):
|
def test_GET_on_file_created_over_mountpoint(self):
|
||||||
|
@ -2872,7 +2872,7 @@ class TestObjectVersioning(Base):
|
|||||||
container = self.env.container
|
container = self.env.container
|
||||||
versions_container = self.env.versions_container
|
versions_container = self.env.versions_container
|
||||||
cont_info = container.info()
|
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()
|
obj_name = Utils.create_name()
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
self.policies_mock = Mock()
|
self.policies_mock = Mock()
|
||||||
self.sof_policy_mock = Mock()
|
self.sof_policy_mock = Mock()
|
||||||
self.sof_policy_mock.name = 'swiftonfile'
|
self.sof_policy_mock.name = 'swiftonfile'
|
||||||
attrs = {'get_by_index.return_value': self.sof_policy_mock }
|
attrs = {'get_by_index.return_value': self.sof_policy_mock}
|
||||||
self.policies_mock.configure_mock(**attrs)
|
self.policies_mock.configure_mock(**attrs)
|
||||||
|
|
||||||
self.test_check = check_constraints.filter_factory(
|
self.test_check = check_constraints.filter_factory(
|
||||||
@ -67,13 +67,13 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
path = '/V1.0/a/c/o'
|
path = '/V1.0/a/c/o'
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'GET'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'GET'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
|
||||||
def test_PUT_container(self):
|
def test_PUT_container(self):
|
||||||
path = '/V1.0/a/c'
|
path = '/V1.0/a/c'
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
|
||||||
def test_PUT_object_with_double_slashes(self):
|
def test_PUT_object_with_double_slashes(self):
|
||||||
path = '/V1.0/a/c2//o'
|
path = '/V1.0/a/c2//o'
|
||||||
@ -85,7 +85,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"POLICIES", self.policies_mock)):
|
"POLICIES", self.policies_mock)):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
self.assertTrue('Invalid object name' in resp.body)
|
self.assertTrue('Invalid object name' in resp.body)
|
||||||
self.assertTrue('cannot begin, end, or have' in resp.body)
|
self.assertTrue('cannot begin, end, or have' in resp.body)
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"POLICIES", self.policies_mock)):
|
"POLICIES", self.policies_mock)):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
self.assertTrue('Invalid object name' in resp.body)
|
self.assertTrue('Invalid object name' in resp.body)
|
||||||
self.assertTrue('can end with a slash only if it is a directory'
|
self.assertTrue('can end with a slash only if it is a directory'
|
||||||
in resp.body)
|
in resp.body)
|
||||||
@ -114,7 +114,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"POLICIES", self.policies_mock)):
|
"POLICIES", self.policies_mock)):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
self.assertTrue('Invalid object name' in resp.body)
|
self.assertTrue('Invalid object name' in resp.body)
|
||||||
self.assertTrue('cannot have . or ..' in resp.body)
|
self.assertTrue('cannot have . or ..' in resp.body)
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
resp = Request.blank(path, method='PUT',
|
resp = Request.blank(path, method='PUT',
|
||||||
headers={'X-Storage-Policy': 'swiftonfile'}
|
headers={'X-Storage-Policy': 'swiftonfile'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
|
|
||||||
# test case where storage policy is not defined in header and
|
# test case where storage policy is not defined in header and
|
||||||
# container would be created in default policy, which happens to be
|
# container would be created in default policy, which happens to be
|
||||||
@ -132,15 +132,15 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
default_policies_mock = Mock()
|
default_policies_mock = Mock()
|
||||||
sof_policy_mock = Mock()
|
sof_policy_mock = Mock()
|
||||||
sof_policy_mock.name = 'swiftonfile'
|
sof_policy_mock.name = 'swiftonfile'
|
||||||
attrs = {'default.return_value': self.sof_policy_mock }
|
attrs = {'default.return_value': self.sof_policy_mock}
|
||||||
default_policies_mock.configure_mock(**attrs)
|
default_policies_mock.configure_mock(**attrs)
|
||||||
with patch("swiftonfile.swift.common.middleware.check_constraints."
|
with patch("swiftonfile.swift.common.middleware.check_constraints."
|
||||||
"POLICIES", default_policies_mock):
|
"POLICIES", default_policies_mock):
|
||||||
resp = Request.blank(path, method='PUT').get_response(self.test_check)
|
resp = Request.blank(path, method='PUT').get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
|
|
||||||
def test_PUT_object_with_long_names(self):
|
def test_PUT_object_with_long_names(self):
|
||||||
for i in (220,221):
|
for i in (220, 221):
|
||||||
longname = 'o' * i
|
longname = 'o' * i
|
||||||
path = '/V1.0/a/c2/' + longname
|
path = '/V1.0/a/c2/' + longname
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"check_constraints.POLICIES", self.policies_mock)):
|
"check_constraints.POLICIES", self.policies_mock)):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
|
||||||
longname = 'o' * 222
|
longname = 'o' * 222
|
||||||
path = '/V1.0/a/c2/' + longname
|
path = '/V1.0/a/c2/' + longname
|
||||||
@ -164,7 +164,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"POLICIES", self.policies_mock)):
|
"POLICIES", self.policies_mock)):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 400)
|
self.assertEqual(resp.status_int, 400)
|
||||||
self.assertTrue('too long' in resp.body)
|
self.assertTrue('too long' in resp.body)
|
||||||
|
|
||||||
def test_PUT_object_with_policy0(self):
|
def test_PUT_object_with_policy0(self):
|
||||||
@ -175,7 +175,7 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
self.container1_info_mock):
|
self.container1_info_mock):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
|
||||||
longname = 'o' * 222
|
longname = 'o' * 222
|
||||||
path = '/V1.0/a/c2/' + longname
|
path = '/V1.0/a/c2/' + longname
|
||||||
@ -184,4 +184,4 @@ class TestConstraintsMiddleware(unittest.TestCase):
|
|||||||
"get_container_info", self.container1_info_mock):
|
"get_container_info", self.container1_info_mock):
|
||||||
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
resp = Request.blank(path, environ={'REQUEST_METHOD': 'PUT'}
|
||||||
).get_response(self.test_check)
|
).get_response(self.test_check)
|
||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEqual(resp.status_int, 200)
|
||||||
|
@ -100,6 +100,7 @@ class MockRenamerCalled(Exception):
|
|||||||
def _mock_renamer(a, b):
|
def _mock_renamer(a, b):
|
||||||
raise MockRenamerCalled()
|
raise MockRenamerCalled()
|
||||||
|
|
||||||
|
|
||||||
class TestDiskFileWriter(unittest.TestCase):
|
class TestDiskFileWriter(unittest.TestCase):
|
||||||
""" Tests for swiftonfile.swift.obj.diskfile.DiskFileWriter """
|
""" Tests for swiftonfile.swift.obj.diskfile.DiskFileWriter """
|
||||||
|
|
||||||
@ -119,6 +120,7 @@ class TestDiskFileWriter(unittest.TestCase):
|
|||||||
self.assertEqual(None, dw._fd)
|
self.assertEqual(None, dw._fd)
|
||||||
self.assertEqual(1, mock_close.call_count)
|
self.assertEqual(1, mock_close.call_count)
|
||||||
|
|
||||||
|
|
||||||
class TestDiskFile(unittest.TestCase):
|
class TestDiskFile(unittest.TestCase):
|
||||||
""" Tests for swiftonfile.swift.obj.diskfile """
|
""" Tests for swiftonfile.swift.obj.diskfile """
|
||||||
|
|
||||||
@ -561,7 +563,7 @@ class TestDiskFile(unittest.TestCase):
|
|||||||
md = {'Content-Type': 'application/octet-stream', 'a': 'b'}
|
md = {'Content-Type': 'application/octet-stream', 'a': 'b'}
|
||||||
gdf.write_metadata(md.copy())
|
gdf.write_metadata(md.copy())
|
||||||
self.assertTrue(_metadata[_mapit(the_file)]['a'], 'b')
|
self.assertTrue(_metadata[_mapit(the_file)]['a'], 'b')
|
||||||
newmd = {'X-Object-Meta-test':'1234'}
|
newmd = {'X-Object-Meta-test': '1234'}
|
||||||
gdf.write_metadata(newmd.copy())
|
gdf.write_metadata(newmd.copy())
|
||||||
on_disk_md = _metadata[_mapit(the_file)]
|
on_disk_md = _metadata[_mapit(the_file)]
|
||||||
self.assertTrue(on_disk_md['Content-Length'], 4)
|
self.assertTrue(on_disk_md['Content-Length'], 4)
|
||||||
@ -604,7 +606,7 @@ class TestDiskFile(unittest.TestCase):
|
|||||||
the_dir = os.path.join(the_cont, "dir")
|
the_dir = os.path.join(the_cont, "dir")
|
||||||
os.makedirs(the_dir)
|
os.makedirs(the_dir)
|
||||||
gdf = self._get_diskfile("vol0", "p57", "ufo47", "bar", "dir")
|
gdf = self._get_diskfile("vol0", "p57", "ufo47", "bar", "dir")
|
||||||
self.assertEquals(gdf._metadata, None)
|
self.assertEqual(gdf._metadata, None)
|
||||||
init_md = {
|
init_md = {
|
||||||
'X-Type': 'Object',
|
'X-Type': 'Object',
|
||||||
'Content-Length': 0,
|
'Content-Length': 0,
|
||||||
@ -632,7 +634,6 @@ class TestDiskFile(unittest.TestCase):
|
|||||||
DIR_OBJECT)
|
DIR_OBJECT)
|
||||||
self.assertFalse('X-Object-Meta-test' in _metadata[_mapit(the_dir)])
|
self.assertFalse('X-Object-Meta-test' in _metadata[_mapit(the_dir)])
|
||||||
|
|
||||||
|
|
||||||
def test_write_metadata_w_meta_file(self):
|
def test_write_metadata_w_meta_file(self):
|
||||||
the_path = os.path.join(self.td, "vol0", "ufo47", "bar")
|
the_path = os.path.join(self.td, "vol0", "ufo47", "bar")
|
||||||
the_file = os.path.join(the_path, "z")
|
the_file = os.path.join(the_path, "z")
|
||||||
|
@ -54,11 +54,11 @@ class TestObjectController(unittest.TestCase):
|
|||||||
environ={'REQUEST_METHOD': 'REPLICATE'},
|
environ={'REQUEST_METHOD': 'REPLICATE'},
|
||||||
headers={})
|
headers={})
|
||||||
resp = req.get_response(self.object_controller)
|
resp = req.get_response(self.object_controller)
|
||||||
self.assertEquals(resp.status_int, 501) # HTTPNotImplemented
|
self.assertEqual(resp.status_int, 501) # HTTPNotImplemented
|
||||||
|
|
||||||
def test_REPLICATION(self):
|
def test_REPLICATION(self):
|
||||||
req = Request.blank('/sda1/p/suff',
|
req = Request.blank('/sda1/p/suff',
|
||||||
environ={'REQUEST_METHOD': 'REPLICATION'},
|
environ={'REQUEST_METHOD': 'REPLICATION'},
|
||||||
headers={})
|
headers={})
|
||||||
resp = req.get_response(self.object_controller)
|
resp = req.get_response(self.object_controller)
|
||||||
self.assertEquals(resp.status_int, 501) # HTTPNotImplemented
|
self.assertEqual(resp.status_int, 501) # HTTPNotImplemented
|
||||||
|
Loading…
Reference in New Issue
Block a user