Fix incorrect usage of assertTrue

Previously assertTrue is incorrectly used as assertEqual or
assertIsNotNone, this patch fixes. Some assertEqual around the changes
introduced by this patch are also updated to use the proper arguments
convention, from
    assertEqual(observed, expected)
to
    assertEqual(expected, observed)

Change-Id: If1d75a850594eff72b69e265a25505382e82022b
Signed-off-by: Zhao Chao <zhaochao1984@gmail.com>
This commit is contained in:
Zhao Chao 2018-02-26 13:45:50 +08:00
parent d6bd37f3f3
commit 3519434b5b
5 changed files with 18 additions and 18 deletions

View File

@ -217,8 +217,8 @@ class AddVolumeFailure(VolumeTest):
snapshot_id=None, name=name, snapshot_id=None, name=name,
description=desc) description=desc)
self.assertEqual(HUGE_VOLUME, volume["size"]) self.assertEqual(HUGE_VOLUME, volume["size"])
self.assertTrue("creating", volume["status"]) self.assertEqual("creating", volume["status"])
self.assertTrue("detached", volume["attach_status"]) self.assertEqual("detached", volume["attach_status"])
self.storyFail.volume = volume self.storyFail.volume = volume
self.storyFail.volume_id = volume["id"] self.storyFail.volume_id = volume["id"]
@ -236,8 +236,8 @@ class AfterVolumeFailureIsAdded(VolumeTest):
"""Wait until the volume is a FAILURE.""" """Wait until the volume is a FAILURE."""
volume = poll_until(lambda: self.storyFail.get_volume(), volume = poll_until(lambda: self.storyFail.get_volume(),
lambda volume: volume["status"] != "creating") lambda volume: volume["status"] != "creating")
self.assertEqual(volume["status"], "error") self.assertEqual("error", volume["status"])
self.assertTrue(volume["attach_status"], "detached") self.assertEqual("detached", volume["attach_status"])
@time_out(60) @time_out(60)
def test_mgmt_volume_check(self): def test_mgmt_volume_check(self):
@ -267,8 +267,8 @@ class AddVolume(VolumeTest):
snapshot_id=None, name=name, snapshot_id=None, name=name,
description=desc) description=desc)
self.assert_volume_as_expected(volume) self.assert_volume_as_expected(volume)
self.assertTrue("creating", volume["status"]) self.assertEqual("creating", volume["status"])
self.assertTrue("detached", volume["attach_status"]) self.assertEqual("detached", volume["attach_status"])
self.story.volume = volume self.story.volume = volume
self.story.volume_id = volume["id"] self.story.volume_id = volume["id"]
@ -286,9 +286,9 @@ class AfterVolumeIsAdded(VolumeTest):
"""Wait until the volume is finished provisioning.""" """Wait until the volume is finished provisioning."""
volume = poll_until(lambda: self.story.get_volume(), volume = poll_until(lambda: self.story.get_volume(),
lambda volume: volume["status"] != "creating") lambda volume: volume["status"] != "creating")
self.assertEqual(volume["status"], "available") self.assertEqual("available", volume["status"])
self.assert_volume_as_expected(volume) self.assert_volume_as_expected(volume)
self.assertTrue(volume["attach_status"], "detached") self.assertEqual("detached", volume["attach_status"])
@time_out(60) @time_out(60)
def test_mgmt_volume_check(self): def test_mgmt_volume_check(self):
@ -404,9 +404,9 @@ class ResizeVolume(VolumeTest):
volume = poll_until(lambda: self.story.get_volume(), volume = poll_until(lambda: self.story.get_volume(),
lambda volume: volume["status"] == "resized") lambda volume: volume["status"] == "resized")
self.assertEqual(volume["status"], "resized") self.assertEqual("resized", volume["status"])
self.assertTrue(volume["attach_status"], "attached") self.assertEqual("attached", volume["attach_status"])
self.assertTrue(volume['size'], self.story.resize_volume_size) self.assertEqual(self.story.resize_volume_size, volume['size'])
@time_out(300) @time_out(300)
def test_resizefs_rescan(self): def test_resizefs_rescan(self):

View File

@ -60,7 +60,7 @@ class TestClusterController(trove_testtools.TestCase):
schema = self.controller.get_schema('create', self.cluster) schema = self.controller.get_schema('create', self.cluster)
self.assertIsNotNone(schema) self.assertIsNotNone(schema)
self.assertIn('cluster', schema['properties']) self.assertIn('cluster', schema['properties'])
self.assertTrue('cluster') self.assertIsNotNone(schema['properties']['cluster'])
def test_validate_create(self): def test_validate_create(self):
body = self.cluster body = self.cluster

View File

@ -74,7 +74,7 @@ class TestClusterController(trove_testtools.TestCase):
schema = self.controller.get_schema('create', self.cluster) schema = self.controller.get_schema('create', self.cluster)
self.assertIsNotNone(schema) self.assertIsNotNone(schema)
self.assertIn('cluster', schema['properties']) self.assertIn('cluster', schema['properties'])
self.assertTrue('cluster') self.assertIsNotNone(schema['properties']['cluster'])
def test_validate_create(self): def test_validate_create(self):
body = self.cluster body = self.cluster

View File

@ -60,7 +60,7 @@ class TestClusterController(trove_testtools.TestCase):
schema = self.controller.get_schema('create', self.cluster) schema = self.controller.get_schema('create', self.cluster)
self.assertIsNotNone(schema) self.assertIsNotNone(schema)
self.assertIn('cluster', schema['properties']) self.assertIn('cluster', schema['properties'])
self.assertTrue('cluster') self.assertIsNotNone(schema['properties']['cluster'])
def test_validate_create(self): def test_validate_create(self):
body = self.cluster body = self.cluster

View File

@ -111,7 +111,7 @@ class TestRootController(trove_testtools.TestCase):
root_controller.root_index = Mock(return_value=ret) root_controller.root_index = Mock(return_value=ret)
service_load_root_controller.return_value = root_controller service_load_root_controller.return_value = root_controller
self.assertTrue(ret, self.controller.index(req, tenant_id, uuid)) self.assertEqual(ret, self.controller.index(req, tenant_id, uuid))
service_get_datastore.assert_called_with(tenant_id, uuid) service_get_datastore.assert_called_with(tenant_id, uuid)
service_load_root_controller.assert_called_with(ds_manager) service_load_root_controller.assert_called_with(ds_manager)
root_controller.root_index.assert_called_with( root_controller.root_index.assert_called_with(
@ -135,7 +135,7 @@ class TestRootController(trove_testtools.TestCase):
root_controller.root_create = Mock(return_value=ret) root_controller.root_create = Mock(return_value=ret)
service_load_root_controller.return_value = root_controller service_load_root_controller.return_value = root_controller
self.assertTrue( self.assertEqual(
ret, self.controller.create(req, tenant_id, uuid, body=body)) ret, self.controller.create(req, tenant_id, uuid, body=body))
service_get_datastore.assert_called_with(tenant_id, uuid) service_get_datastore.assert_called_with(tenant_id, uuid)
service_load_root_controller.assert_called_with(ds_manager) service_load_root_controller.assert_called_with(ds_manager)
@ -280,8 +280,8 @@ class TestClusterRootController(trove_testtools.TestCase):
cluster_instances = [db_inst_1, db_inst_2] cluster_instances = [db_inst_1, db_inst_2]
mock_find_all.return_value.all.return_value = cluster_instances mock_find_all.return_value.all.return_value = cluster_instances
ret = self.controller._get_cluster_instance_id(tenant_id, cluster_id) ret = self.controller._get_cluster_instance_id(tenant_id, cluster_id)
self.assertTrue(db_inst_1.id, ret[0]) self.assertEqual(db_inst_1.id, ret[0])
self.assertTrue(cluster_instances, ret[1]) self.assertEqual([db_inst_1.id, db_inst_2.id], ret[1])
@patch.object(models.ClusterRoot, "create") @patch.object(models.ClusterRoot, "create")
def test_instance_root_create(self, mock_cluster_root_create): def test_instance_root_create(self, mock_cluster_root_create):