From 1ebbfd3dc1694dc4f26e763da9eee833bb5d2545 Mon Sep 17 00:00:00 2001 From: Sabari Kumar Murugesan Date: Thu, 28 Jan 2016 14:01:55 -0800 Subject: [PATCH] Remove glance_store specific unit tests TestStoreAddToBackend contains a set of tests that should belong to the glance_store. Recently, these tests were about to break glance as they mocked internal methods. Those mocks were removed in commit eab1567d48a18fa968c7b66c3641dd037da1f84e. The tests are added back to glance_store in change https://review.openstack.org/#/c/273786. Depends-On: I688629d37e9146aef33fbc9bb6fd8780521e06ab Change-Id: Ic67826a4d02cb30cc429a3d4abc46d6ca96f31ad --- glance/tests/unit/test_store_image.py | 85 --------------------------- 1 file changed, 85 deletions(-) diff --git a/glance/tests/unit/test_store_image.py b/glance/tests/unit/test_store_image.py index ae6921e71c..1d80894c72 100644 --- a/glance/tests/unit/test_store_image.py +++ b/glance/tests/unit/test_store_image.py @@ -910,88 +910,3 @@ class TestStoreMetaDataChecker(utils.BaseTestCase): self.assertRaises(glance_store.BackendException, glance_store.check_location_metadata, m) - - -class TestStoreAddToBackend(utils.BaseTestCase): - - def setUp(self): - super(TestStoreAddToBackend, self).setUp() - self.image_id = "animage" - self.data = "dataandstuff" - self.size = len(self.data) - self.location = "file:///ab/cde/fgh" - self.checksum = "md5" - - def _bad_metadata(self, in_metadata): - mstore = mock.Mock() - mstore.add.return_value = (self.location, self.size, - self.checksum, in_metadata) - mstore.__str__ = lambda self: "hello" - mstore.__unicode__ = lambda self: "hello" - - self.assertRaises(glance_store.BackendException, - glance_store.store_add_to_backend, - self.image_id, - self.data, - self.size, - mstore) - - def _good_metadata(self, in_metadata): - mstore = mock.Mock() - mstore.add.return_value = (self.location, self.size, - self.checksum, in_metadata) - - (location, - size, - checksum, - metadata) = glance_store.store_add_to_backend(self.image_id, - self.data, - self.size, - mstore) - - self.assertEqual(self.location, location) - self.assertEqual(self.size, size) - self.assertEqual(self.checksum, checksum) - self.assertEqual(in_metadata, metadata) - - def test_empty(self): - metadata = {} - self._good_metadata(metadata) - - def test_string(self): - metadata = {'key': u'somevalue'} - self._good_metadata(metadata) - - def test_list(self): - m = {'key': [u'somevalue', u'2']} - self._good_metadata(m) - - def test_unicode_dict(self): - inner = {'key1': u'somevalue', 'key2': u'somevalue'} - m = {'topkey': inner} - self._good_metadata(m) - - def test_unicode_dict_list(self): - inner = {'key1': u'somevalue', 'key2': u'somevalue'} - m = {'topkey': inner, 'list': [u'somevalue', u'2'], 'u': u'2'} - self._good_metadata(m) - - def test_nested_dict(self): - inner = {'key1': u'somevalue', 'key2': u'somevalue'} - inner = {'newkey': inner} - inner = {'anotherkey': inner} - m = {'topkey': inner} - self._good_metadata(m) - - def test_bad_top_level_nonunicode(self): - metadata = {'key': b'a string'} - self._bad_metadata(metadata) - - def test_bad_nonunicode_dict_list(self): - inner = {'key1': u'somevalue', 'key2': u'somevalue', - 'k3': [1, object()]} - m = {'topkey': inner, 'list': [u'somevalue', u'2'], 'u': u'2'} - self._bad_metadata(m) - - def test_bad_metadata_not_dict(self): - self._bad_metadata([])