Exemplo n.º 1
0
def make_test_LocalstackSession(*args, **kwargs):
    """Make a test LocalstackSession that doesn't actually run Localstack."""
    docker_client = make_mock_docker_client()
    test_session = session.LocalstackSession(docker_client, *args, **kwargs)

    test_session._check_services = mock.Mock(
        return_value=None,
        __name__=test_session._check_services.__name__,
        __code__=test_session._check_services.__code__,
    )

    return test_session
Exemplo n.º 2
0
def test_LocalstackSession_individual_services(test_service, docker_client):
    """Test that each service can run individually."""
    test_session = session.LocalstackSession(docker_client,
                                             services=[test_service])
    with test_session:
        for service_name, service_check in service_checks.SERVICE_CHECKS.items(
        ):
            if service_name == test_service:
                service_check(test_session)
            else:
                with pytest.raises(exceptions.ServiceError):
                    test_session.service_hostname(test_session)
Exemplo n.º 3
0
def _make_session(docker_client, *args, **kwargs):
    utils.check_proxy_env_vars()

    if docker_client is None:
        docker_client = docker.from_env()

    try:
        docker_client.ping()  # Check connectivity
    except docker.errors.APIError:
        pytest.fail("Could not connect to Docker.")

    _session = session.LocalstackSession(docker_client, *args, **kwargs)

    _session.start(timeout=_start_timeout)
    try:
        yield _session
    finally:
        _session.stop(timeout=_stop_timeout)
Exemplo n.º 4
0
def _make_session(docker_client, *args, **kwargs):
    if pytest.config.getoption("--no-localstack"):
        pytest.skip("skipping because --no-localstack is set")

    utils.check_proxy_env_vars()

    if docker_client is None:
        docker_client = docker.from_env()

    try:
        docker_client.ping()  # Check connectivity
    except docker.errors.APIError:
        pytest.fail("Could not connect to Docker.")

    _session = session.LocalstackSession(docker_client, *args, **kwargs)

    start_timeout = pytest.config.getoption("--localstack-start-timeout")
    stop_timeout = pytest.config.getoption("--localstack-stop-timeout")

    _session.start(timeout=start_timeout)
    try:
        yield _session
    finally:
        _session.stop(timeout=stop_timeout)