Skip to content

Commit

Permalink
Do not rely on dogpile internals for mocks
Browse files Browse the repository at this point in the history
Nova tests are broken under dogpile.cache===0.6.3 because of
https://bitbucket.org/zzzeek/dogpile.cache/commits/7f81a5ab304e9fe1a279168ee5f68d9077edb512

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
  • Loading branch information
dims committed May 30, 2017
1 parent d6a4b44 commit eb22047
Showing 1 changed file with 2 additions and 33 deletions.
35 changes: 2 additions & 33 deletions nova/tests/unit/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,6 @@ def test_get_default_cache_region_default_expiration_time(self):
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,
Expand Down Expand Up @@ -82,9 +55,5 @@ def test_get_memcached_client(self, mock_cacheregion):
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)

0 comments on commit eb22047

Please sign in to comment.