Merge "Remove glance_store specific unit tests"

This commit is contained in:
Jenkins 2016-02-04 05:41:49 +00:00 committed by Gerrit Code Review
commit 397deafb3a

View File

@ -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([])