]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Extend unit tests for backup get_all
authorEric Harney <eharney@redhat.com>
Tue, 25 Aug 2015 17:54:29 +0000 (13:54 -0400)
committerEric Harney <eharney@redhat.com>
Tue, 25 Aug 2015 18:05:56 +0000 (14:05 -0400)
With ddt we can easily unit test the range of
expected inputs for these calls.

Change-Id: I6f2783dfec9aaae46a77f946f5ac8f99a698a2c8

cinder/tests/unit/test_backup.py

index 238b527091c509daa77b076c5c63f3291384c594..f943409ed3847265b79e3b065a49b1e1fcf0a51a 100644 (file)
@@ -893,6 +893,7 @@ class BackupTestCaseWithVerify(BaseBackupTest):
         self.assertEqual('error', backup['status'])
 
 
+@ddt.ddt
 class BackupAPITestCase(BaseBackupTest):
     def setUp(self):
         super(BackupAPITestCase, self).setUp()
@@ -912,8 +913,10 @@ class BackupAPITestCase(BaseBackupTest):
             self.ctxt, self.ctxt.project_id, filters={'key': 'value'})
 
     @mock.patch.object(objects, 'BackupList')
-    def test_get_all_false_value_all_tenants(self, mock_backuplist):
-        result = self.api.get_all(self.ctxt, {'all_tenants': '0',
+    @ddt.data(False, 'false', '0', 0, 'no')
+    def test_get_all_false_value_all_tenants(
+            self, false_value, mock_backuplist):
+        result = self.api.get_all(self.ctxt, {'all_tenants': false_value,
                                               'key': 'value'})
         self.assertFalse(mock_backuplist.get_all.called)
         self.assertEqual(mock_backuplist.get_all_by_project.return_value,
@@ -922,8 +925,10 @@ class BackupAPITestCase(BaseBackupTest):
             self.ctxt, self.ctxt.project_id, filters={'key': 'value'})
 
     @mock.patch.object(objects, 'BackupList')
-    def test_get_all_true_value_all_tenants(self, mock_backuplist):
-        result = self.api.get_all(self.ctxt, {'all_tenants': 'true',
+    @ddt.data(True, 'true', '1', 1, 'yes')
+    def test_get_all_true_value_all_tenants(
+            self, true_value, mock_backuplist):
+        result = self.api.get_all(self.ctxt, {'all_tenants': true_value,
                                               'key': 'value'})
         self.assertFalse(mock_backuplist.get_all_by_project.called)
         self.assertEqual(mock_backuplist.get_all.return_value,