def test_tries_all_calls_despite_exceptions(self, env_setup, push_tuples, specs, mocker): fail_specs = [specs[0], specs[-1]] expected_calls = [call(spec) for spec in specs] async def raise_(spec, *args, **kwargs): if spec in fail_specs: raise exception.CloneFailedError( "Some error", returncode=128, stderr=b"Something", clone_spec=spec, ) clone_mock = mocker.patch( "_repobee.git._fetch._clone_async", autospec=True, side_effect=raise_, ) failed_specs = git.clone(specs) assert failed_specs == fail_specs clone_mock.assert_has_calls(expected_calls)
def test_happy_path(self, env_setup, push_tuples, specs, aio_subproc): expected_subproc_calls = [ call( *f"git pull {spec.repo_url}".split(), cwd=str(spec.dest), stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) for spec in specs ] failed_specs = git.clone(specs) assert not failed_specs aio_subproc.create_subprocess.assert_has_calls(expected_subproc_calls)
def test_tries_all_calls_despite_exceptions_lower_level( self, env_setup, push_tuples, mocker, non_zero_aio_subproc, specs): """Same test as test_tries_all_calls_desipite_exception, but asyncio.create_subprocess_exec is mocked out instead of git._clone_async """ expected_calls = [ call( *f"git pull {spec.repo_url}".split(), cwd=str(spec.dest), stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) for spec in specs ] failed_specs = git.clone(specs) non_zero_aio_subproc.create_subprocess.assert_has_calls(expected_calls) assert failed_specs == specs