Allow save to be called more than once

Replace check for single call with ensuring that it is called at least
once.

As mock patching affects global state by patching the class rather than
the instance, other tests creating the CacheStorage object via separate
test threads can result in the 'save' method being called more than
once. Therefore just test to ensure that it has been called at least
once.

Change-Id: Ice3d13536bafa04713f4c226273898806926067d
This commit is contained in:
Darragh Bailey
2015-09-22 14:56:39 +01:00
parent 59a8342f85
commit 709f233bca

View File

@@ -32,7 +32,7 @@ class TestCaseCacheStorage(testtools.TestCase):
with mock.patch('jenkins_jobs.builder.CacheStorage.save') as save_mock:
with mock.patch('os.path.isfile', return_value=False):
jenkins_jobs.builder.CacheStorage("dummy")
save_mock.assert_called_once_with()
save_mock.assert_called_with()
@mock.patch('jenkins_jobs.builder.CacheStorage.get_cache_dir',
lambda x: '/bad/file')