def test_get_url_no_save(self, _): """ Calls to get_url() doesn't save if autocommit=False """ cache = ICache(MagicMock()) cache.autocommit = False with patch.object(cache, 'save') as save: package = make_package() cache.get_url(package) self.assertFalse(save.called)
def test_get_url_saves(self, _): """ Calls to get_url() saves to caching db if autocommit=True """ cache = ICache(MagicMock()) with patch.object(cache, 'save') as save: cache.autocommit = True package = make_package() cache.get_url(package) save.assert_called_with(package)