summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-05-11 17:44:23 -0700
committerJoffrey F <joffrey@docker.com>2017-05-12 14:28:27 -0700
commit95297dc2e760b992d7d31d485a66d02728944f36 (patch)
tree5ef3893b1c2850a6dd5d9f0db3f9bd6cde55f586 /tests
parent007ab677a1ff7748596ca7703ad05d89a4c881cd (diff)
downloaddocker-py-1433-run-networks.tar.gz
Replace erroneous networks argument in containers.run with singular1433-run-networks
network equivalent. Small docfixes Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/models_containers_test.py19
-rw-r--r--tests/unit/models_containers_test.py5
2 files changed, 21 insertions, 3 deletions
diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py
index 4f1e6a1..b76a88f 100644
--- a/tests/integration/models_containers_test.py
+++ b/tests/integration/models_containers_test.py
@@ -1,6 +1,7 @@
import docker
import tempfile
from .base import BaseIntegrationTest, TEST_API_VERSION
+from ..helpers import random_name
class ContainerCollectionTest(BaseIntegrationTest):
@@ -69,6 +70,24 @@ class ContainerCollectionTest(BaseIntegrationTest):
)
self.assertEqual(out, b'hello\n')
+ def test_run_with_network(self):
+ net_name = random_name()
+ client = docker.from_env(version=TEST_API_VERSION)
+ client.networks.create(net_name)
+ self.tmp_networks.append(net_name)
+
+ container = client.containers.run(
+ 'alpine', 'echo hello world', network=net_name,
+ detach=True
+ )
+ self.tmp_containers.append(container.id)
+
+ attrs = container.attrs
+
+ assert 'NetworkSettings' in attrs
+ assert 'Networks' in attrs['NetworkSettings']
+ assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name]
+
def test_get(self):
client = docker.from_env(version=TEST_API_VERSION)
container = client.containers.run("alpine", "sleep 300", detach=True)
diff --git a/tests/unit/models_containers_test.py b/tests/unit/models_containers_test.py
index 0fb69f3..70c8648 100644
--- a/tests/unit/models_containers_test.py
+++ b/tests/unit/models_containers_test.py
@@ -71,8 +71,7 @@ class ContainerCollectionTest(unittest.TestCase):
memswap_limit=456,
name='somename',
network_disabled=False,
- network_mode='blah',
- networks=['foo'],
+ network='foo',
oom_kill_disable=True,
oom_score_adj=5,
pid_mode='host',
@@ -153,7 +152,7 @@ class ContainerCollectionTest(unittest.TestCase):
'MemoryReservation': 123,
'MemorySwap': 456,
'MemorySwappiness': 2,
- 'NetworkMode': 'blah',
+ 'NetworkMode': 'foo',
'OomKillDisable': True,
'OomScoreAdj': 5,
'PidMode': 'host',