forked from testcontainers/testcontainers-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docker_compose.py
More file actions
33 lines (24 loc) · 1.09 KB
/
test_docker_compose.py
File metadata and controls
33 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest
from testcontainers.compose import DockerCompose
from testcontainers.core.docker_client import DockerClient
from testcontainers.core.exceptions import NoSuchPortExposed
def test_can_spawn_service_via_compose():
with DockerCompose("tests") as compose:
host = compose.get_service_host("hub", 4444)
port = compose.get_service_port("hub", 4444)
assert host == "0.0.0.0"
assert port == "4444"
def test_can_pull_images_before_spawning_service_via_compose():
with DockerCompose("tests", pull=True) as compose:
host = compose.get_service_host("hub", 4444)
port = compose.get_service_port("hub", 4444)
assert host == "0.0.0.0"
assert port == "4444"
def test_can_throw_exception_if_no_port_exposed():
with DockerCompose("tests") as compose:
with pytest.raises(NoSuchPortExposed):
compose.get_service_host("hub", 5555)
def test_compose_wait_for_container_ready():
with DockerCompose("tests") as compose:
docker = DockerClient()
compose.wait_for("http://%s:4444/wd/hub" % docker.host())