forked from testcontainers/testcontainers-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docker_client.py
More file actions
26 lines (20 loc) · 818 Bytes
/
test_docker_client.py
File metadata and controls
26 lines (20 loc) · 818 Bytes
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
from unittest.mock import MagicMock, patch
import docker
from testcontainers.core.docker_client import DockerClient
from testcontainers.core.container import DockerContainer
def test_docker_client_from_env():
test_kwargs = dict(
test_kw="test_value"
)
mock_docker = MagicMock(spec=docker)
with patch("testcontainers.core.docker_client.docker", mock_docker):
DockerClient(**test_kwargs)
mock_docker.from_env.assert_called_with(**test_kwargs)
def test_container_docker_client_kw():
test_kwargs = dict(
test_kw="test_value"
)
mock_docker = MagicMock(spec=docker)
with patch("testcontainers.core.docker_client.docker", mock_docker):
DockerContainer(image="", docker_client_kw=test_kwargs)
mock_docker.from_env.assert_called_with(**test_kwargs)