]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix order of arguments in assertEqual
authorchenying <ying.chen@huawei.com>
Tue, 25 Aug 2015 02:35:37 +0000 (10:35 +0800)
committerchenying <ying.chen@huawei.com>
Sat, 5 Sep 2015 07:18:22 +0000 (15:18 +0800)
Some tests used incorrect order assertEqual(observed, expected).
The correct order expected by testtools is
assertEqual(expected, observed).
This patch does not cover v1 api tests and vendor unit tests.

Partial-Bug: #1486906
Change-Id: I4671cc75c999d22ea9c181c515c67d03b7d54c71

cinder/tests/unit/api/contrib/test_cgsnapshots.py
cinder/tests/unit/api/contrib/test_volume_image_metadata.py
cinder/tests/unit/api/contrib/test_volume_replication.py
cinder/tests/unit/api/contrib/test_volume_tenant_attribute.py
cinder/tests/unit/api/contrib/test_volume_unmanage.py
cinder/tests/unit/api/test_common.py
cinder/tests/unit/api/test_extensions.py
cinder/tests/unit/integrated/test_xml.py
cinder/tests/unit/keymgr/test_barbican.py
cinder/tests/unit/test_backup.py

index 61266b6a495cd27c17e48cfeda8817053662f84a..2eab1e4416351ff2da0473b7921fc1dc86a6ccb3 100644 (file)
@@ -148,16 +148,16 @@ class CgsnapshotsAPITestCase(test.TestCase):
         res_dict = json.loads(res.body)
 
         self.assertEqual(200, res.status_int)
-        self.assertEqual(res_dict['cgsnapshots'][0]['id'],
-                         cgsnapshot_id1)
+        self.assertEqual(cgsnapshot_id1,
+                         res_dict['cgsnapshots'][0]['id'])
         self.assertEqual('test_cgsnapshot',
                          res_dict['cgsnapshots'][0]['name'])
-        self.assertEqual(res_dict['cgsnapshots'][1]['id'],
-                         cgsnapshot_id2)
+        self.assertEqual(cgsnapshot_id2,
+                         res_dict['cgsnapshots'][1]['id'])
         self.assertEqual('test_cgsnapshot',
                          res_dict['cgsnapshots'][1]['name'])
-        self.assertEqual(res_dict['cgsnapshots'][2]['id'],
-                         cgsnapshot_id3)
+        self.assertEqual(cgsnapshot_id3,
+                         res_dict['cgsnapshots'][2]['id'])
         self.assertEqual('test_cgsnapshot',
                          res_dict['cgsnapshots'][2]['name'])
 
@@ -193,12 +193,12 @@ class CgsnapshotsAPITestCase(test.TestCase):
         dom = minidom.parseString(res.body)
         cgsnapshot_list = dom.getElementsByTagName('cgsnapshot')
 
-        self.assertEqual(cgsnapshot_list.item(0).getAttribute('id'),
-                         cgsnapshot_id1)
-        self.assertEqual(cgsnapshot_list.item(1).getAttribute('id'),
-                         cgsnapshot_id2)
-        self.assertEqual(cgsnapshot_list.item(2).getAttribute('id'),
-                         cgsnapshot_id3)
+        self.assertEqual(cgsnapshot_id1,
+                         cgsnapshot_list.item(0).getAttribute('id'))
+        self.assertEqual(cgsnapshot_id2,
+                         cgsnapshot_list.item(1).getAttribute('id'))
+        self.assertEqual(cgsnapshot_id3,
+                         cgsnapshot_list.item(2).getAttribute('id'))
 
         db.cgsnapshot_destroy(context.get_admin_context(),
                               cgsnapshot_id3)
@@ -234,8 +234,8 @@ class CgsnapshotsAPITestCase(test.TestCase):
                          res_dict['cgsnapshots'][0]['description'])
         self.assertEqual('test_cgsnapshot',
                          res_dict['cgsnapshots'][0]['name'])
-        self.assertEqual(res_dict['cgsnapshots'][0]['id'],
-                         cgsnapshot_id1)
+        self.assertEqual(cgsnapshot_id1,
+                         res_dict['cgsnapshots'][0]['id'])
         self.assertEqual('creating',
                          res_dict['cgsnapshots'][0]['status'])
 
@@ -243,17 +243,17 @@ class CgsnapshotsAPITestCase(test.TestCase):
                          res_dict['cgsnapshots'][1]['description'])
         self.assertEqual('test_cgsnapshot',
                          res_dict['cgsnapshots'][1]['name'])
-        self.assertEqual(res_dict['cgsnapshots'][1]['id'],
-                         cgsnapshot_id2)
+        self.assertEqual(cgsnapshot_id2,
+                         res_dict['cgsnapshots'][1]['id'])
         self.assertEqual('creating',
                          res_dict['cgsnapshots'][1]['status'])
 
         self.assertEqual('this is a test cgsnapshot',
                          res_dict['cgsnapshots'][2]['description'])
-        self.assertEqual(res_dict['cgsnapshots'][2]['name'],
-                         'test_cgsnapshot')
-        self.assertEqual(res_dict['cgsnapshots'][2]['id'],
-                         cgsnapshot_id3)
+        self.assertEqual('test_cgsnapshot',
+                         res_dict['cgsnapshots'][2]['name'])
+        self.assertEqual(cgsnapshot_id3,
+                         res_dict['cgsnapshots'][2]['id'])
         self.assertEqual('creating',
                          res_dict['cgsnapshots'][2]['status'])
         db.cgsnapshot_destroy(context.get_admin_context(),
@@ -292,26 +292,26 @@ class CgsnapshotsAPITestCase(test.TestCase):
                          cgsnapshot_detail.item(0).getAttribute('description'))
         self.assertEqual('test_cgsnapshot',
                          cgsnapshot_detail.item(0).getAttribute('name'))
-        self.assertEqual(cgsnapshot_detail.item(0).getAttribute('id'),
-                         cgsnapshot_id1)
+        self.assertEqual(cgsnapshot_id1,
+                         cgsnapshot_detail.item(0).getAttribute('id'))
         self.assertEqual('creating',
                          cgsnapshot_detail.item(0).getAttribute('status'))
 
-        self.assertEqual(cgsnapshot_detail.item(1).getAttribute('description'),
-                         'this is a test cgsnapshot')
+        self.assertEqual('this is a test cgsnapshot',
+                         cgsnapshot_detail.item(1).getAttribute('description'))
         self.assertEqual('test_cgsnapshot',
                          cgsnapshot_detail.item(1).getAttribute('name'))
-        self.assertEqual(cgsnapshot_detail.item(1).getAttribute('id'),
-                         cgsnapshot_id2)
+        self.assertEqual(cgsnapshot_id2,
+                         cgsnapshot_detail.item(1).getAttribute('id'))
         self.assertEqual('creating',
                          cgsnapshot_detail.item(1).getAttribute('status'))
 
-        self.assertEqual(cgsnapshot_detail.item(2).getAttribute('description'),
-                         'this is a test cgsnapshot')
+        self.assertEqual('this is a test cgsnapshot',
+                         cgsnapshot_detail.item(2).getAttribute('description'))
         self.assertEqual('test_cgsnapshot',
                          cgsnapshot_detail.item(2).getAttribute('name'))
-        self.assertEqual(cgsnapshot_detail.item(2).getAttribute('id'),
-                         cgsnapshot_id3)
+        self.assertEqual(cgsnapshot_id3,
+                         cgsnapshot_detail.item(2).getAttribute('id'))
         self.assertEqual('creating',
                          cgsnapshot_detail.item(2).getAttribute('status'))
 
index 3d9642e4ae38fd497da323449f26ec1d3bb4235f..dd9ed0108387df317997e556d0478afe48b02b49 100644 (file)
@@ -118,14 +118,14 @@ class VolumeImageMetadataTest(test.TestCase):
     def test_get_volume(self):
         res = self._make_request('/v2/fake/volumes/%s' % self.UUID)
         self.assertEqual(200, res.status_int)
-        self.assertEqual(self._get_image_metadata(res.body),
-                         fake_image_metadata)
+        self.assertEqual(fake_image_metadata,
+                         self._get_image_metadata(res.body))
 
     def test_list_detail_volumes(self):
         res = self._make_request('/v2/fake/volumes/detail')
         self.assertEqual(200, res.status_int)
-        self.assertEqual(self._get_image_metadata_list(res.body)[0],
-                         fake_image_metadata)
+        self.assertEqual(fake_image_metadata,
+                         self._get_image_metadata_list(res.body)[0])
 
     def test_create_image_metadata(self):
         self.stubs.Set(volume.API, 'get_volume_image_metadata',
index 8de27087fad00d900b82a46fa22ec21bb28d07c9..f71874e9bbb685b97aee7b1ea9ac4bc50e8a3bfc 100644 (file)
@@ -70,12 +70,12 @@ class VolumeReplicationAPITestCase(test.TestCase):
     def test_promote_bad_id(self):
         (req, res) = self._get_resp('promote', 'fake')
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 404, msg)
+        self.assertEqual(404, res.status_int, msg)
 
     def test_promote_bad_id_xml(self):
         (req, res) = self._get_resp('promote', 'fake', xml=True)
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 404, msg)
+        self.assertEqual(404, res.status_int, msg)
 
     def test_promote_volume_not_replicated(self):
         volume = tests_utils.create_volume(
@@ -83,7 +83,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
             **self.volume_params)
         (req, res) = self._get_resp('promote', volume['id'])
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 400, msg)
+        self.assertEqual(400, res.status_int, msg)
 
     def test_promote_volume_not_replicated_xml(self):
         volume = tests_utils.create_volume(
@@ -91,7 +91,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
             **self.volume_params)
         (req, res) = self._get_resp('promote', volume['id'], xml=True)
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 400, msg)
+        self.assertEqual(400, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.promote_replica')
     def test_promote_replication_volume_status(self,
@@ -103,7 +103,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['available']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -112,7 +112,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.promote_replica')
     def test_promote_replication_volume_status_xml(self,
@@ -124,7 +124,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['available']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -133,7 +133,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.promote_replica')
     def test_promote_replication_replication_status(self,
@@ -145,7 +145,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['active', 'active-stopped']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -154,7 +154,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.promote_replica')
     def test_promote_replication_replication_status_xml(self,
@@ -166,7 +166,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['active', 'active-stopped']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -175,17 +175,17 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('promote', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
 
     def test_reenable_bad_id(self):
         (req, res) = self._get_resp('reenable', 'fake')
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 404, msg)
+        self.assertEqual(404, res.status_int, msg)
 
     def test_reenable_bad_id_xml(self):
         (req, res) = self._get_resp('reenable', 'fake', xml=True)
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 404, msg)
+        self.assertEqual(404, res.status_int, msg)
 
     def test_reenable_volume_not_replicated(self):
         volume = tests_utils.create_volume(
@@ -193,7 +193,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
             **self.volume_params)
         (req, res) = self._get_resp('reenable', volume['id'])
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 400, msg)
+        self.assertEqual(400, res.status_int, msg)
 
     def test_reenable_volume_not_replicated_xml(self):
         volume = tests_utils.create_volume(
@@ -201,7 +201,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
             **self.volume_params)
         (req, res) = self._get_resp('reenable', volume['id'], xml=True)
         msg = ("request: %s\nresult: %s" % (req, res))
-        self.assertEqual(res.status_int, 400, msg)
+        self.assertEqual(400, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.reenable_replication')
     def test_reenable_replication_replication_status(self,
@@ -213,7 +213,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('reenable', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['inactive', 'active-stopped', 'error']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -222,7 +222,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('reenable', volume['id'])
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
 
     @mock.patch('cinder.volume.rpcapi.VolumeAPI.reenable_replication')
     def test_reenable_replication_replication_status_xml(self,
@@ -234,7 +234,7 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('reenable', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 400, msg)
+            self.assertEqual(400, res.status_int, msg)
 
         for status in ['inactive', 'active-stopped', 'error']:
             volume = tests_utils.create_volume(self.ctxt,
@@ -243,4 +243,4 @@ class VolumeReplicationAPITestCase(test.TestCase):
                                                **self.volume_params)
             (req, res) = self._get_resp('reenable', volume['id'], xml=True)
             msg = ("request: %s\nresult: %s" % (req, res))
-            self.assertEqual(res.status_int, 202, msg)
+            self.assertEqual(202, res.status_int, msg)
index 1c2db15793a6bd45d52b1845770cbdfdfae549a1..702634e7490ee3398d697951be12a2aab1d43944 100644 (file)
@@ -74,7 +74,7 @@ class VolumeTenantAttributeTest(test.TestCase):
         req.environ['cinder.context'] = ctx
         res = req.get_response(app())
         vol = json.loads(res.body)['volume']
-        self.assertEqual(vol['os-vol-tenant-attr:tenant_id'], PROJECT_ID)
+        self.assertEqual(PROJECT_ID, vol['os-vol-tenant-attr:tenant_id'])
 
     def test_get_volume_unallowed(self):
         ctx = context.RequestContext('non-admin', 'fake', False)
@@ -92,7 +92,7 @@ class VolumeTenantAttributeTest(test.TestCase):
         req.environ['cinder.context'] = ctx
         res = req.get_response(app())
         vol = json.loads(res.body)['volumes']
-        self.assertEqual(vol[0]['os-vol-tenant-attr:tenant_id'], PROJECT_ID)
+        self.assertEqual(PROJECT_ID, vol[0]['os-vol-tenant-attr:tenant_id'])
 
     def test_list_detail_volumes_unallowed(self):
         ctx = context.RequestContext('non-admin', 'fake', False)
@@ -122,7 +122,7 @@ class VolumeTenantAttributeTest(test.TestCase):
         vol = etree.XML(res.body)
         tenant_key = ('{http://docs.openstack.org/volume/ext/'
                       'volume_tenant_attribute/api/v2}tenant_id')
-        self.assertEqual(vol.get(tenant_key), PROJECT_ID)
+        self.assertEqual(PROJECT_ID, vol.get(tenant_key))
 
     def test_list_volumes_detail_xml(self):
         ctx = context.RequestContext('admin', 'fake', True)
@@ -134,4 +134,4 @@ class VolumeTenantAttributeTest(test.TestCase):
         vol = list(etree.XML(res.body))[0]
         tenant_key = ('{http://docs.openstack.org/volume/ext/'
                       'volume_tenant_attribute/api/v2}tenant_id')
-        self.assertEqual(vol.get(tenant_key), PROJECT_ID)
+        self.assertEqual(PROJECT_ID, vol.get(tenant_key))
index f3313e4ba322223c72f4e6990ff5c47e6d711e81..c7f5fc5363b0750bf4fa398eed876cbd87988cf5 100644 (file)
@@ -139,7 +139,7 @@ class VolumeUnmanageTest(test.TestCase):
         # volume_update is (context, id, new_data)
         self.assertEqual(1, mock_db.call_count)
         self.assertEqual(3, len(mock_db.call_args[0]), mock_db.call_args)
-        self.assertEqual(mock_db.call_args[0][1], detached_vol_id)
+        self.assertEqual(detached_vol_id, mock_db.call_args[0][1])
 
         # delete_volume is (context, status, unmanageOnly)
         self.assertEqual(1, mock_rpcapi.call_count)
index 8050a5e7d330951752df424300710f973ff3652e..db2f1c1087d705dee567b793e93f3bce03cb1a00 100644 (file)
@@ -72,7 +72,7 @@ class LimiterTest(test.TestCase):
         self.assertEqual([], common.limited(self.small, req))
         self.assertEqual([], common.limited(self.medium, req))
         self.assertEqual(
-            common.limited(self.large, req), self.large[1001:2001])
+            self.large[1001:2001], common.limited(self.large, req))
 
     def test_limiter_offset_blank(self):
         """Test offset key works with a blank offset."""
index 9e2dc415610fa031c2bce5740d07b6406d11533d..90f6c343575a66dbe74dffb0a63b0d82b756fa2f 100644 (file)
@@ -83,8 +83,7 @@ class ExtensionControllerTest(ExtensionTestCase):
             request = webob.Request.blank(url)
             response = request.get_response(app)
             output = jsonutils.loads(response.body)
-            self.assertEqual(output['extension']['alias'],
-                             ext['alias'])
+            self.assertEqual(ext['alias'], output['extension']['alias'])
 
     def test_get_extension_json(self):
         app = router.APIRouter()
@@ -115,7 +114,7 @@ class ExtensionControllerTest(ExtensionTestCase):
         self.assertEqual(200, response.status_int)
 
         root = etree.XML(response.body)
-        self.assertEqual(root.tag.split('extensions')[0], NS)
+        self.assertEqual(NS, root.tag.split('extensions')[0])
 
         # Make sure we have all the extensions, extras extensions being OK.
         exts = root.findall('{0}extension'.format(NS))
@@ -143,7 +142,7 @@ class ExtensionControllerTest(ExtensionTestCase):
         xml = response.body
 
         root = etree.XML(xml)
-        self.assertEqual(root.tag.split('extension')[0], NS)
+        self.assertEqual(NS, root.tag.split('extension')[0])
         self.assertEqual('FOXNSOX', root.get('alias'))
         self.assertEqual('Fox In Socks', root.get('name'))
         self.assertEqual(
index 00ff457b07f4f7105b19d4628465879bcae81a67..3bda0cee863b0a36ceac3cfeca4d3e666eb7fe1a 100644 (file)
@@ -46,4 +46,4 @@ class XmlTests(integrated_helpers._IntegratedTestBase):
         data = response.raw
         LOG.warning("data: %s", data)
         root = etree.parse(data).getroot()
-        self.assertEqual(root.nsmap.get(None), common.XML_NS_V2)
+        self.assertEqual(common.XML_NS_V2, root.nsmap.get(None))
index d8a25c15b2a7358f6565ebdfb247388796093c77..d52d682ee499987cd239aee4af12a1df9006d0ef 100644 (file)
@@ -149,7 +149,7 @@ class BarbicanKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):
         returned_uuid = self.key_mgr.create_key(self.ctxt)
 
         self.mock_barbican.orders.get.assert_called_once_with(order_ref_url)
-        self.assertEqual(returned_uuid, self.key_id)
+        self.assertEqual(self.key_id, returned_uuid)
 
     def test_create_null_context(self):
         self.key_mgr._barbican_client = None
@@ -177,7 +177,7 @@ class BarbicanKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):
 
         self.get.assert_called_once_with(self.secret_ref)
         encoded = array.array('B', binascii.unhexlify(self.hex)).tolist()
-        self.assertEqual(key.get_encoded(), encoded)
+        self.assertEqual(encoded, key.get_encoded())
 
     def test_get_null_context(self):
         self.key_mgr._barbican_client = None
@@ -207,7 +207,7 @@ class BarbicanKeyManagerTestCase(test_key_mgr.KeyManagerTestCase):
                                             'base64',
                                             'AES', 32, 'CBC',
                                             None)
-        self.assertEqual(returned_uuid, self.key_id)
+        self.assertEqual(self.key_id, returned_uuid)
 
     def test_store_key_plaintext(self):
         # Create the plaintext key
index 52278d71589ba19999de85f817cdd3bf83c1a98c..b8a31fdff0e45f2e609897f999c6fac83a01c24a 100644 (file)
@@ -556,7 +556,7 @@ class BackupTestCase(BaseBackupTest):
         b2 = self._create_backup_db_entry(project_id='project1')
         backups = db.backup_get_all_by_project(self.ctxt, 'project1')
         self.assertEqual(1, len(backups))
-        self.assertEqual(backups[0].id, b2.id)
+        self.assertEqual(b2.id, backups[0].id)
 
     def test_backup_get_all_by_project_with_deleted(self):
         """Test deleted backups.
@@ -573,7 +573,7 @@ class BackupTestCase(BaseBackupTest):
 
         backups = db.backup_get_all_by_project(self.ctxt, 'fake')
         self.assertEqual(1, len(backups))
-        self.assertEqual(backups[0].id, backup_keep.id)
+        self.assertEqual(backup_keep.id, backups[0].id)
 
         ctxt_read_deleted = context.get_admin_context('yes')
         backups = db.backup_get_all_by_project(ctxt_read_deleted, 'fake')
@@ -594,7 +594,7 @@ class BackupTestCase(BaseBackupTest):
 
         backups = db.backup_get_all_by_host(self.ctxt, 'testhost')
         self.assertEqual(1, len(backups))
-        self.assertEqual(backups[0].id, backup_keep.id)
+        self.assertEqual(backup_keep.id, backups[0].id)
 
         ctxt_read_deleted = context.get_admin_context('yes')
         backups = db.backup_get_all_by_host(ctxt_read_deleted, 'testhost')