'Test that the cache is saved on normal object deletion'

@mock.patch('jenkins_jobs.builder.JobCache.get_cache_dir', (lambda x: '/bad/file'))
def test_save_on_exit(self):

    with mock.patch('jenkins_jobs.builder.JobCache.save') as save_mock:
        with mock.patch('os.path.isfile', return_value=False):
            with mock.patch('jenkins_jobs.builder.JobCache._lock'):
                jenkins_jobs.builder.JobCache('dummy')
        save_mock.assert_called_with()
