Updated unit tests to use official unittest methods
Fixed many instances of `assert something` to `self.assertTrue(something)` or whatever applies for that particular test Change-Id: Iddce97e48dff25183c91f598c18db4943260110a
This commit is contained in:
parent
57d40f7603
commit
3e15a1286a
@ -245,7 +245,7 @@ class LimitMiddlewareTest(BaseLimitTestSuite):
|
||||
|
||||
def test_limit_class(self):
|
||||
"""Test that middleware selected correct limiter class."""
|
||||
assert isinstance(self.app._limiter, TestLimiter)
|
||||
self.assertIsInstance(self.app._limiter, TestLimiter)
|
||||
|
||||
def test_good_request(self):
|
||||
"""Test successful GET request through middleware."""
|
||||
@ -339,7 +339,7 @@ class ParseLimitsTest(BaseLimitTestSuite):
|
||||
'(POST, /bar*, /bar.*, 5, second);'
|
||||
'(Say, /derp*, /derp.*, 1, day)')
|
||||
except ValueError as e:
|
||||
assert False, e
|
||||
self.fail(msg=e)
|
||||
|
||||
# Make sure the number of returned limits are correct
|
||||
self.assertEqual(4, len(l))
|
||||
|
@ -594,4 +594,4 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_init):
|
||||
stats = self.driver.get_volume_stats(False)
|
||||
self.assertEqual('FC', stats['storage_protocol'])
|
||||
assert mock_get_storage_usage.called is False
|
||||
mock_get_storage_usage.assert_not_called()
|
||||
|
@ -3544,7 +3544,7 @@ Time Remaining: 0 second(s)
|
||||
self.testData.test_volume_with_type,
|
||||
self.testData.test_existing_ref)
|
||||
expected = [mock.call(*get_lun_cmd, poll=True)]
|
||||
assert get_size == test_size
|
||||
self.assertEqual(test_size, get_size)
|
||||
fake_cli.assert_has_calls(expected)
|
||||
# Test the function with invalid reference.
|
||||
invaild_ref = {'fake': 'fake_ref'}
|
||||
|
@ -1340,7 +1340,7 @@ class NetAppCmodeNfsDriverOnlyTestCase(test.TestCase):
|
||||
drv._get_export_path.assert_called_with(volume.id)
|
||||
drv._check_share_can_hold_size.assert_called_with('share', 1)
|
||||
|
||||
assert drv._execute.call_count == 1
|
||||
self.assertEqual(1, drv._execute.call_count)
|
||||
drv._post_clone_image.assert_called_with(volume)
|
||||
|
||||
@mock.patch.object(image_utils, 'convert_image')
|
||||
@ -1381,9 +1381,9 @@ class NetAppCmodeNfsDriverOnlyTestCase(test.TestCase):
|
||||
drv._get_ip_verify_on_cluster.assert_any_call('ip1')
|
||||
drv._get_export_path.assert_called_with(volume.id)
|
||||
drv._check_share_can_hold_size.assert_called_with('share', 1)
|
||||
assert mock_cvrt_image.call_count == 1
|
||||
assert drv._execute.call_count == 1
|
||||
assert drv._delete_file_at_path.call_count == 2
|
||||
self.assertEqual(1, mock_cvrt_image.call_count)
|
||||
self.assertEqual(1, drv._execute.call_count)
|
||||
self.assertEqual(2, drv._delete_file_at_path.call_count)
|
||||
drv._clone_file_dst_exists.call_count == 1
|
||||
drv._post_clone_image.assert_called_with(volume)
|
||||
|
||||
|
@ -587,8 +587,8 @@ class QuobyteDriverTestCase(test.TestCase):
|
||||
|
||||
drv.delete_volume(volume)
|
||||
|
||||
assert not drv._ensure_share_mounted.called
|
||||
assert not drv._execute.called
|
||||
drv._ensure_share_mounted.assert_not_called()
|
||||
drv._execute.assert_not_called()
|
||||
|
||||
def test_extend_volume(self):
|
||||
drv = self._driver
|
||||
|
@ -39,7 +39,7 @@ class IsolationTestCase(test.TestCase):
|
||||
class NeverCalled(object):
|
||||
|
||||
def __getattribute__(*args):
|
||||
assert False, "I should never get called."
|
||||
self.fail(msg="I should never get called.")
|
||||
|
||||
server = rpc.get_server(messaging.Target(topic='volume',
|
||||
server=cfg.CONF.host),
|
||||
|
@ -64,7 +64,7 @@ class TestVolumeDriver(test.TestCase):
|
||||
as mock_safe_get:
|
||||
mock_safe_get.return_value = 'fabric'
|
||||
self.driver.no_zone_initialize_connection(None, None)
|
||||
assert not add_zone_mock.called
|
||||
add_zone_mock.assert_not_called()
|
||||
|
||||
@mock.patch('oslo_config.cfg._is_opt_registered', return_value=False)
|
||||
@mock.patch.object(utils, 'require_driver_initialized')
|
||||
@ -87,4 +87,4 @@ class TestVolumeDriver(test.TestCase):
|
||||
as mock_safe_get:
|
||||
mock_safe_get.return_value = 'fabric'
|
||||
self.driver.no_zone_terminate_connection(None, None)
|
||||
assert not remove_zone_mock.called
|
||||
remove_zone_mock.assert_not_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user