code: def test_partial_push_n_pull(  # noqa: C901
      tmp_dir, dvc, tmp_path_factory, local_remote, mocker
  ):
      from dvc_objects.fs import generic
  
      foo = tmp_dir.dvc_gen({"foo": "foo content"})[0].outs[0]
      bar = tmp_dir.dvc_gen({"bar": "bar content"})[0].outs[0]
      baz = tmp_dir.dvc_gen({"baz": {"foo": "foo content"}})[0].outs[0]
  
      # Faulty upload version, failing on foo
      original = generic.transfer
      odb = dvc.cloud.get_remote_odb("upstream")
  
      def unreliable_upload(
          from_fs, from_info, to_fs, to_info, **kwargs
      ):
          on_error = kwargs["on_error"]
          assert on_error
          if isinstance(from_info, str):
              from_info = [from_info]
          else:
              from_info = list(from_info)
          if isinstance(to_info, str):
              to_info = [to_info]
          else:
              to_info = list(to_info)
          for i in range(len(from_info) - 1, -1, -1):
              from_i = from_info[i]
              to_i = to_info[i]
              if os.path.abspath(to_i) == os.path.abspath(
                  odb.get(foo.hash_info.value).path
              ):
                  if on_error:
                      on_error(from_i, to_i, Exception("stop foo"))
                  del from_info[i]
                  del to_info[i]
          return original(from_fs, from_info, to_fs, to_info, **kwargs)
  
      mock_upload = mocker.patch.object(
          generic, "transfer", unreliable_upload
      )
      with pytest.raises(UploadError) as upload_error_info:
          dvc.push()
      assert upload_error_info.value.amount == 2
  
      assert not odb.exists(foo.hash_info.value)
      assert odb.exists(bar.hash_info.value)
      assert not odb.exists(baz.hash_info.value)
      mocker.stop(mock_upload)
  
      # Push everything and delete local cache
      dvc.push()
      dvc.cache.local.clear()
  
      baz._collect_used_dir_cache()
  
      def unreliable_download(
          _from_fs, from_info, _to_fs, to_info, **kwargs
      ):
          on_error = kwargs["on_error"]
          assert on_error
          if isinstance(from_info, str):
              from_info = [from_info]
          if isinstance(to_info, str):
              to_info = [to_info]
          for from_i, to_i in zip(from_info, to_info):
              on_error(from_i, to_i, Exception())
  
      mock_download = mocker.patch.object(
          generic, "transfer", unreliable_download
      )
      with pytest.raises(DownloadError) as download_error_info:
          dvc.pull()
      # error count should be len(.dir + standalone file checksums)
      # since files inside dir are ignored if dir cache entry is missing
      assert download_error_info.value.amount == 2
      mocker.stop(mock_download)
  
imports: import errno
  import itertools
  import os
  import stat
  import configobj
  import pytest
  from dvc.cli import main
  from dvc.config import Config
  from dvc.exceptions import DownloadError, UploadError
  from dvc.utils.fs import remove
label_desc: Use image node_id 11 for calling a global function with example usage: test_partial_push_n_pull(tmp_dir, dvc, tmp_path_factory, local_remote, mocker) and returns: original