]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Improve coverage for snapshot_get_by_host
authorVipin Balachandran <vbala@vmware.com>
Thu, 10 Sep 2015 06:42:44 +0000 (12:12 +0530)
committerVipin Balachandran <vbala@vmware.com>
Thu, 10 Sep 2015 07:05:18 +0000 (12:35 +0530)
Commit cf3cfb3a66066cfdc1ad15ac35b204d4a7b0301f modified
snapshot_get_by_host method (in db/sqlalchemy/api.py) to
return an empty list if the host argument is None or empty.
This patch updates the unit test to cover this case.

Change-Id: If09ac7587df8c4a3eae84b162d76f4168507aa52

cinder/tests/unit/test_db_api.py

index d732f61ee5c180e0d5fd7a302f239c365b1accfa..79878e55397669f862a26cb0ebbc59c6dd68445e 100644 (file)
@@ -1148,6 +1148,9 @@ class DBAPISnapshotTestCase(BaseTest):
                                             self.ctxt,
                                             'host2', {'fake_key': 'fake'}),
                                         ignored_keys='volume')
+        # If host is None or empty string, empty list should be returned.
+        self.assertEqual([], db.snapshot_get_by_host(self.ctxt, None))
+        self.assertEqual([], db.snapshot_get_by_host(self.ctxt, ''))
 
     def test_snapshot_get_by_host_with_pools(self):
         db.volume_create(self.ctxt, {'id': 1, 'host': 'host1#pool1'})