def test_docker_run_with_root_flag(self): ctx = self.get_ctx(root=True) ctx.znake.docker.run.flags = ['--my-flag 3'] target = {'image': 'my_image'} command = 'this is my command' with patch('znake.docker._docker_pull') as pull, patch('znake.docker._docker_run') as run: docker_run(ctx, target['image'], command) expected_image_name = 'docker.zenterio.lan/zenterio/' + 'my_image' pull.assert_called_once_with(ctx, expected_image_name) run.assert_called_once_with( ctx, '--my-flag 3', expected_image_name, command, interactive=False)
def test_docker_run_with_interactive(self): ctx = self.get_ctx() ctx.znake.docker.run.flags = ['--my-flag 3'] target = {'image': 'my_image'} command = 'this is my command' with patch('znake.docker._docker_pull'), patch('znake.docker._docker_run') as run: docker_run(ctx, target['image'], command, interactive=True) expected_image_name = 'docker.zenterio.lan/zenterio/' + 'my_image' run.assert_called_once_with( ctx, '--my-flag 3 --user "$(id -u):$(id -g)" -it', expected_image_name, command, interactive=True)
def test_docker_run_with_no_registry_flag(self): ctx = self.get_ctx() target = {'image': 'my_image'} command = 'this is my command' with patch('znake.docker._docker_pull') as pull, patch( 'znake.docker._docker_run') as run: docker_run(ctx, target['image'], command) expected_image_name = 'my_image' pull.assert_called_once_with(ctx, expected_image_name) run.assert_called_once_with(ctx, '--user "$(id -u):$(id -g)"', expected_image_name, command, interactive=False)
def test_docker_run_with_no_pull_flag(self): ctx = self.get_ctx(no_pull=True, registry='my.docker.registry/repository') ctx.znake.docker.run.flags = ['--my-flag 3'] target = {'image': 'my_image'} command = 'this is my command' with patch('znake.docker._docker_pull') as pull, patch( 'znake.docker._docker_run') as run: docker_run(ctx, target['image'], command) expected_image_name = 'my.docker.registry/repository/' + 'my_image' pull.assert_not_called() run.assert_called_once_with(ctx, '--my-flag 3 --user "$(id -u):$(id -g)"', expected_image_name, command, interactive=False)