def test_compose_multiple_containers_and_ports():
    """test for the logic encapsulated in 'one' function

    assert correctness of multiple logic
    """
    multiple = DockerCompose(context=FIXTURES / "port_multiple")
    with multiple:
        with pytest.raises(ContainerIsNotRunning) as e:
            multiple.get_container()
            e.match("get_container failed")
            e.match("not exactly 1 container")

        assert multiple.get_container("alpine")
        assert multiple.get_container("alpine2")

        a2p = multiple.get_service_port("alpine2")
        assert a2p > 0  # > 1024

        with pytest.raises(NoSuchPortExposed) as e:
            multiple.get_service_port("alpine")
            e.match("not exactly 1")
        with pytest.raises(NoSuchPortExposed) as e:
            multiple.get_container("alpine").get_publisher(by_host="example.com")
            e.match("not exactly 1")
        with pytest.raises(NoSuchPortExposed) as e:
            multiple.get_container("alpine").get_publisher(by_host="localhost")
            e.match("not exactly 1")

        try:
            # this fails when ipv6 is enabled and docker is forwarding for both 4 + 6
            multiple.get_container(service_name="alpine").get_publisher(by_port=81, prefer_ip_version="IPv6")
        except:  # noqa
            pass

        ports = [
            (
                80,
                multiple.get_service_host(service_name="alpine", port=80),
                multiple.get_service_port(service_name="alpine", port=80),
            ),
            (
                81,
                multiple.get_service_host(service_name="alpine", port=81),
                multiple.get_service_port(service_name="alpine", port=81),
            ),
            (
                82,
                multiple.get_service_host(service_name="alpine", port=82),
                multiple.get_service_port(service_name="alpine", port=82),
            ),
        ]

        # test correctness of port lookup
        for target, host, mapped in ports:
            assert mapped, f"we have a mapped port for target port {target}"
            url = f"http://{host}:{mapped}"
            code, body = fetch(Request(method="GET", url=url))

            expected_code = {
                80: 200,
                81: 202,
                82: 204,
            }.get(code, None)

            if not expected_code:
                continue

            message = f"response '{body}' ({code}) from url {url} should have code {expected_code}"
            assert code == expected_code, message
test for the logic encapsulated in 'one' function

    assert correctness of multiple logic
    
core/tests/test_compose.py