Do not rely on dogpile internals for mocks

Nova tests are broken under dogpile.cache===0.6.3 because of
7f81a5ab30

We need to fix the following tests to make sure we don't rely on
the arguments or order of arguments.
nova.tests.unit.test_cache.TestOsloCache.test_get_memcached_client

We can remove the following test as there is nothing much left
of actual value
nova.tests.unit.test_cache.TestOsloCache.test_get_client

Change-Id: I6fc342db2abb365d9e791b2f53701627d2a2beed
This commit is contained in:
Davanum Srinivas 2017-05-28 20:09:28 -04:00 committed by Davanum Srinivas (dims)
parent d6a4b44050
commit eb22047abd

View File

@ -28,33 +28,6 @@ class TestOsloCache(test.NoDBTestCase):
self.assertEqual(600, region.expiration_time)
self.assertIsNotNone(region)
@mock.patch('dogpile.cache.region.CacheRegion.configure')
def test_get_client(self, mock_cacheregion):
self.assertIsNotNone(
cache_utils.get_client(expiration_time=60))
self.flags(group='cache', enabled=True)
self.assertIsNotNone(
cache_utils.get_client(expiration_time=60))
self.flags(group='cache', enabled=False)
client = cache_utils.get_client(expiration_time=60)
self.assertIsNotNone(client.region)
mock_cacheregion.assert_has_calls(
[mock.call('oslo_cache.dict',
arguments={'expiration_time': 60},
expiration_time=60),
mock.call('dogpile.cache.null',
_config_argument_dict=mock.ANY,
_config_prefix='cache.oslo.arguments.',
expiration_time=60,
wrap=None),
mock.call('oslo_cache.dict',
arguments={'expiration_time': 60},
expiration_time=60)],
)
@mock.patch('dogpile.cache.region.CacheRegion.configure')
def test_get_custom_cache_region(self, mock_cacheregion):
self.assertRaises(RuntimeError,
@ -82,9 +55,5 @@ class TestOsloCache(test.NoDBTestCase):
self.assertIsNotNone(
cache_utils.get_memcached_client(expiration_time=60))
mock_cacheregion.assert_has_calls(
[mock.call('dogpile.cache.null',
_config_argument_dict=mock.ANY,
_config_prefix='cache.oslo.arguments.',
expiration_time=60, wrap=None)]
)
methods_called = [a[0] for n, a, k in mock_cacheregion.mock_calls]
self.assertEqual(['dogpile.cache.null'], methods_called)