From 5e533d95552da588a823df9baf72eaf77da9d136 Mon Sep 17 00:00:00 2001 From: Vipin Balachandran Date: Thu, 10 Sep 2015 12:12:44 +0530 Subject: [PATCH] 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 --- cinder/tests/unit/test_db_api.py | 3 +++ 1 file changed, 3 insertions(+) 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'}) -- 2.45.2