From: Vipin Balachandran Date: Thu, 10 Sep 2015 06:42:44 +0000 (+0530) Subject: Improve coverage for snapshot_get_by_host X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5e533d95552da588a823df9baf72eaf77da9d136;p=openstack-build%2Fcinder-build.git Improve coverage for snapshot_get_by_host 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 --- diff --git a/cinder/tests/unit/test_db_api.py b/cinder/tests/unit/test_db_api.py index d732f61ee..79878e553 100644 --- a/cinder/tests/unit/test_db_api.py +++ b/cinder/tests/unit/test_db_api.py @@ -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'})