def test_cache_for_existing_root(self, mock_path_exists, mock_makedirs, mock_open): mock_path_exists.return_value = True mock_file_handle = mock_open.return_value.__enter__.return_value store = FileSystemBackingStore(60) store.cache("get_templates", {"foo": "bar"}) self.assertFalse(mock_makedirs.called) mock_file_handle.write.assert_called_once_with("\x80\x02}q\x01U\x03fooq\x02U\x03barq\x03s.")
def test_cache_file_open_exc_handling(self, mock_path_exists, mock_open): mock_path_exists.return_value = True mock_open.side_effect = IOError() store = FileSystemBackingStore(60) store.cache("get_templates", {"foo": "bar"})
def test_cache_create_root_exc_handling(self, mock_path_exists, mock_makedirs): mock_path_exists.return_value = False mock_makedirs.side_effect = IOError() store = FileSystemBackingStore(60) store.cache("get_templates", {"foo": "bar"})