Ejemplo n.º 1
0
def test_execute():
    docker_compose = DockerComposeExecutor("docker-compose.yml", "pytest123")
    with mock.patch('subprocess.check_output') as check_output:
        docker_compose.execute("up")
        assert check_output.call_args_list == [
            mock.call(
                'docker-compose -f "docker-compose.yml" -p "pytest123" up',
                shell=True,
                stderr=subprocess.STDOUT,
            ),
        ]
Ejemplo n.º 2
0
def test_pypath_compose_files():
    compose_file = py.path.local('/tmp/docker-compose.yml')
    docker_compose = DockerComposeExecutor(compose_file, "pytest123")
    with mock.patch('subprocess.check_output') as check_output:
        docker_compose.execute("up")
        assert check_output.call_args_list == [
            mock.call(
                'docker-compose -f "/tmp/docker-compose.yml"'
                ' -p "pytest123" up',
                shell=True,
                stderr=subprocess.STDOUT,
            ),
        ]
Ejemplo n.º 3
0
def test_wait_until_responsive_timeout():
    clock = mock.MagicMock()
    clock.side_effect = [0.0, 1.0, 2.0, 3.0]

    with mock.patch('time.sleep') as sleep:
        docker_compose = DockerComposeExecutor(
            compose_files='docker-compose.yml',
            compose_project_name="pytest123")
        services = Services(docker_compose)
        with pytest.raises(Exception) as exc:
            print(
                services.wait_until_responsive(
                    check=lambda: False,
                    timeout=3.0,
                    pause=1.0,
                    clock=clock,
                ))
        assert sleep.call_args_list == [
            mock.call(1.0),
            mock.call(1.0),
            mock.call(1.0),
        ]
    assert str(exc.value) == ('Timeout reached while waiting on service!')