Fix unittests due mock 1.1.0 release

More info:
http://lists.openstack.org/pipermail/openstack-dev/2015-July/069156.html

Closes-Bug: #1473383
Change-Id: Ic2f3addb757fc748d565a49a24938306cd9f04b2
This commit is contained in:
Lucas Alvares Gomes 2015-07-13 10:04:39 +01:00
parent aea764b451
commit 3305c78aa2
2 changed files with 23 additions and 16 deletions

View File

@ -54,9 +54,10 @@ class FileCacheTest(utils.BaseTestCase):
self.assertEqual(0, mock_exists.call_count)
self.assertEqual(0, mock_makedirs.call_count)
@mock.patch.object(filecache, 'CACHE', autospec=True)
def test_save_data_ok(self, mock_cache):
mock_cache.set = mock.Mock(spec=dogpile.cache.region.CacheRegion.set)
@mock.patch.object(dogpile.cache.region, 'CacheRegion', autospec=True)
@mock.patch.object(filecache, '_get_cache', autospec=True)
def test_save_data_ok(self, mock_get_cache, mock_cache):
mock_get_cache.return_value = mock_cache
host = 'fred'
port = '1234'
hostport = '%s:%s' % (host, port)
@ -65,12 +66,13 @@ class FileCacheTest(utils.BaseTestCase):
mock_cache.set.assert_called_once_with(hostport, data)
@mock.patch.object(os.path, 'isfile', autospec=True)
@mock.patch.object(filecache, 'CACHE', autospec=True)
def test_retrieve_data_ok(self, mock_cache, mock_isfile):
@mock.patch.object(dogpile.cache.region, 'CacheRegion', autospec=True)
@mock.patch.object(filecache, '_get_cache', autospec=True)
def test_retrieve_data_ok(self, mock_get_cache, mock_cache, mock_isfile):
s = 'spam'
mock_isfile.return_value = True
mock_cache.get = mock.Mock(spec=dogpile.cache.region.CacheRegion.get,
return_value=s)
mock_cache.get.return_value = s
mock_get_cache.return_value = mock_cache
host = 'fred'
port = '1234'
hostport = '%s:%s' % (host, port)
@ -79,12 +81,14 @@ class FileCacheTest(utils.BaseTestCase):
self.assertEqual(s, result)
@mock.patch.object(os.path, 'isfile', autospec=True)
@mock.patch.object(filecache, 'CACHE', autospec=True)
def test_retrieve_data_ok_with_expiry(self, mock_cache, mock_isfile):
@mock.patch.object(dogpile.cache.region, 'CacheRegion', autospec=True)
@mock.patch.object(filecache, '_get_cache', autospec=True)
def test_retrieve_data_ok_with_expiry(self, mock_get_cache, mock_cache,
mock_isfile):
s = 'spam'
mock_isfile.return_value = True
mock_cache.get = mock.Mock(spec=dogpile.cache.region.CacheRegion.get,
return_value=s)
mock_cache.get.return_value = s
mock_get_cache.return_value = mock_cache
host = 'fred'
port = '1234'
expiry = '987'
@ -95,11 +99,13 @@ class FileCacheTest(utils.BaseTestCase):
self.assertEqual(s, result)
@mock.patch.object(os.path, 'isfile', autospec=True)
@mock.patch.object(filecache, 'CACHE', autospec=True)
def test_retrieve_data_not_found(self, mock_cache, mock_isfile):
@mock.patch.object(dogpile.cache.region, 'CacheRegion', autospec=True)
@mock.patch.object(filecache, '_get_cache', autospec=True)
def test_retrieve_data_not_found(self, mock_get_cache, mock_cache,
mock_isfile):
mock_isfile.return_value = True
mock_cache.get = mock.Mock(spec=dogpile.cache.region.CacheRegion.get,
return_value=dogpile.cache.api.NO_VALUE)
mock_cache.get.return_value = dogpile.cache.api.NO_VALUE
mock_get_cache.return_value = mock_cache
host = 'fred'
port = '1234'
hostport = '%s:%s' % (host, port)

View File

@ -7,7 +7,8 @@ discover
fixtures>=1.3.1
hacking<0.11,>=0.10.0
httpretty<0.8.7,>=0.8.4
mock>=1.0
mock==1.0.1;python_version=='2.6'
mock>=1.1;python_version!='2.6'
oslosphinx>=2.5.0 # Apache-2.0
python-subunit>=0.0.18
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2