Skip to content

Commit

Permalink
Fix Archery tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pitrou committed Aug 7, 2024
1 parent f38e1c2 commit 2e4f12f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions dev/archery/archery/docker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ def _mock_compose_calls(compose):
from types import MethodType
from subprocess import CompletedProcess

def _mock(compose, executable):
def _mock(compose, command_tuple):
def _execute(self, *args, **kwargs):
params = ['{}={}'.format(k, v)
params = [f'{k}={v}'
for k, v in self.config.params.items()]
command = ' '.join(params + [executable] + list(args))
command = ' '.join(params + command_tuple + args)
click.echo(command)
return CompletedProcess([], 0)
return MethodType(_execute, compose)

compose._execute_docker = _mock(compose, executable='docker')
compose._execute_compose = _mock(compose, executable='docker-compose')
compose._execute_docker = _mock(compose, command_tuple=('docker',))
compose._execute_compose = _mock(compose, command_tuple=('docker', 'compose'))


@click.group()
Expand Down
2 changes: 1 addition & 1 deletion dev/archery/archery/docker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class DockerCompose(Command):
def __init__(self, config_path, dotenv_path=None, compose_bin=None,
using_docker=False, using_buildx=False, params=None,
debug=False):
compose_bin = default_bin(compose_bin, 'docker-compose')
compose_bin = default_bin(compose_bin, 'docker compose')
self.config = ComposeConfig(config_path, dotenv_path, compose_bin,
params=params, using_docker=using_docker,
using_buildx=using_buildx, debug=debug)
Expand Down
6 changes: 3 additions & 3 deletions dev/archery/archery/docker/tests/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def assert_docker_calls(compose, expected_args):


def assert_compose_calls(compose, expected_args, env=mock.ANY):
base_command = ['docker-compose', '--file', str(compose.config.path)]
base_command = ['docker', 'compose', f'--file={compose.config.path}']
expected_commands = []
for args in expected_args:
if isinstance(args, str):
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_compose_push(arrow_compose_path):
]
for image in ["conda-cpp", "conda-python", "conda-python-pandas"]:
expected_calls.append(
mock.call(["docker-compose", "--file", str(compose.config.path),
mock.call(["docker", "compose", f"--file={compose.config.path}",
"push", image], check=True, env=expected_env)
)
with assert_subprocess_calls(expected_calls):
Expand Down Expand Up @@ -514,7 +514,7 @@ def test_image_with_gpu(arrow_compose_path):
"run", "--rm", "--gpus", "all",
"-e", "CUDA_ENV=1",
"-e", "OTHER_ENV=2",
"-v", "/host:/container:rw",
"-v", "/host:/container",
"org/ubuntu-cuda",
"/bin/bash", "-c", "echo 1 > /tmp/dummy && cat /tmp/dummy",
]
Expand Down

0 comments on commit 2e4f12f

Please sign in to comment.