コード例 #1
0
ファイル: test_docker.py プロジェクト: andni233/opensourcelib
    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)
コード例 #2
0
ファイル: test_docker.py プロジェクト: andni233/opensourcelib
    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)
コード例 #3
0
ファイル: test_docker.py プロジェクト: andni233/znake
    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)
コード例 #4
0
ファイル: test_docker.py プロジェクト: andni233/znake
    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)