From bb6e04d40a02a211579602207b0143047cd3e9c1 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Wed, 26 Aug 2015 12:56:14 +0530 Subject: [PATCH] Add unit test for backup get_all 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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cinder/tests/unit/test_backup.py b/cinder/tests/unit/test_backup.py index f943409ed..329cce0fe 100644 --- a/cinder/tests/unit/test_backup.py +++ b/cinder/tests/unit/test_backup.py @@ -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'}) -- 2.45.2