]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add unit test for backup get_all
authorVipin Balachandran <vbala@vmware.com>
Wed, 26 Aug 2015 07:26:14 +0000 (12:56 +0530)
committerVipin Balachandran <vbala@vmware.com>
Wed, 26 Aug 2015 07:26:14 +0000 (12:56 +0530)
This patch adds a missing unit test for backup get_all to test
the case where the option 'all_tenants' is true and the context
is non-admin.

Change-Id: I282641c45871c980588240a64be45409de4835d0

cinder/tests/unit/test_backup.py

index f943409ed3847265b79e3b065a49b1e1fcf0a51a..329cce0fe3660988dd9117ea68ec72e3821d47b5 100644 (file)
@@ -935,3 +935,14 @@ class BackupAPITestCase(BaseBackupTest):
                          result)
         mock_backuplist.get_all.assert_called_once_with(
             self.ctxt, filters={'key': 'value'})
+
+    @mock.patch.object(objects, 'BackupList')
+    def test_get_all_true_value_all_tenants_non_admin(self, mock_backuplist):
+        ctxt = context.RequestContext('fake', 'fake')
+        result = self.api.get_all(ctxt, {'all_tenants': '1',
+                                         'key': 'value'})
+        self.assertFalse(mock_backuplist.get_all.called)
+        self.assertEqual(mock_backuplist.get_all_by_project.return_value,
+                         result)
+        mock_backuplist.get_all_by_project.assert_called_once_with(
+            ctxt, ctxt.project_id, filters={'key': 'value'})