diff options
Diffstat (limited to 'glanceclient/tests/unit/v2')
-rw-r--r-- | glanceclient/tests/unit/v2/test_images.py | 60 | ||||
-rw-r--r-- | glanceclient/tests/unit/v2/test_shell_v2.py | 8 |
2 files changed, 68 insertions, 0 deletions
diff --git a/glanceclient/tests/unit/v2/test_images.py b/glanceclient/tests/unit/v2/test_images.py index 753f3c4..99926de 100644 --- a/glanceclient/tests/unit/v2/test_images.py +++ b/glanceclient/tests/unit/v2/test_images.py @@ -26,6 +26,10 @@ from glanceclient.v2 import images _CHKSUM = '93264c3edf5972c9f1cb309543d38a5c' _CHKSUM1 = '54264c3edf5972c9f1cb309453d38a46' +_HASHVAL = '54264c3edf93264c3edf5972c9f1cb309543d38a5c5972c9f1cb309453d38a46' +_HASHVAL1 = 'cb309543d38a5c5972c9f1cb309453d38a4654264c3edf93264c3edf5972c9f1' +_HASHBAD = '93264c3edf597254264c3edf5972c9f1cb309453d38a46c9f1cb309543d38a5c' + _TAG1 = 'power' _TAG2 = '64bit' @@ -457,6 +461,41 @@ data_fixtures = { {'images': []}, ), }, + '/v2/images?limit=%d&os_hash_value=%s' % (images.DEFAULT_PAGE_SIZE, + _HASHVAL): { + 'GET': ( + {}, + {'images': [ + { + 'id': '3a4560a1-e585-443e-9b39-553b46ec92d1', + 'name': 'image-1', + } + ]}, + ), + }, + '/v2/images?limit=%d&os_hash_value=%s' % (images.DEFAULT_PAGE_SIZE, + _HASHVAL1): { + 'GET': ( + {}, + {'images': [ + { + 'id': '2a4560b2-e585-443e-9b39-553b46ec92d1', + 'name': 'image-1', + }, + { + 'id': '6f99bf80-2ee6-47cf-acfe-1f1fabb7e810', + 'name': 'image-2', + }, + ]}, + ), + }, + '/v2/images?limit=%d&os_hash_value=%s' % (images.DEFAULT_PAGE_SIZE, + _HASHBAD): { + 'GET': ( + {}, + {'images': []}, + ), + }, '/v2/images?limit=%d&tag=%s' % (images.DEFAULT_PAGE_SIZE, _TAG1): { 'GET': ( {}, @@ -754,6 +793,27 @@ class TestController(testtools.TestCase): images = self.controller.list(**filters) self.assertEqual(0, len(images)) + def test_list_images_for_hash_single_image(self): + fake_id = '3a4560a1-e585-443e-9b39-553b46ec92d1' + filters = {'filters': {'os_hash_value': _HASHVAL}} + images = self.controller.list(**filters) + self.assertEqual(1, len(images)) + self.assertEqual('%s' % fake_id, images[0].id) + + def test_list_images_for_hash_multiple_images(self): + fake_id1 = '2a4560b2-e585-443e-9b39-553b46ec92d1' + fake_id2 = '6f99bf80-2ee6-47cf-acfe-1f1fabb7e810' + filters = {'filters': {'os_hash_value': _HASHVAL1}} + images = self.controller.list(**filters) + self.assertEqual(2, len(images)) + self.assertEqual('%s' % fake_id1, images[0].id) + self.assertEqual('%s' % fake_id2, images[1].id) + + def test_list_images_for_wrong_hash(self): + filters = {'filters': {'os_hash_value': _HASHBAD}} + images = self.controller.list(**filters) + self.assertEqual(0, len(images)) + def test_list_images_for_bogus_owner(self): filters = {'filters': {'owner': _BOGUS_ID}} images = self.controller.list(**filters) diff --git a/glanceclient/tests/unit/v2/test_shell_v2.py b/glanceclient/tests/unit/v2/test_shell_v2.py index 919e645..bafa8e5 100644 --- a/glanceclient/tests/unit/v2/test_shell_v2.py +++ b/glanceclient/tests/unit/v2/test_shell_v2.py @@ -265,6 +265,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': False, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -302,6 +303,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': True, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -328,6 +330,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': False, 'include_stores': True, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -353,6 +356,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': True, 'include_stores': True, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -379,6 +383,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': False, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': True } args = self._make_args(input) @@ -416,6 +421,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': False, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -453,6 +459,7 @@ class ShellV2Test(testtools.TestCase): 'sort_dir': [], 'verbose': False, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) @@ -490,6 +497,7 @@ class ShellV2Test(testtools.TestCase): 'sort': None, 'verbose': False, 'include_stores': False, + 'os_hash_value': None, 'os_hidden': False } args = self._make_args(input) |