Skip to content

Commit 46093e2

Browse files
committed
Move LinksTest to appropriate file
Signed-off-by: Joffrey F <[email protected]>
1 parent c0ebb69 commit 46093e2

File tree

2 files changed

+45
-43
lines changed

2 files changed

+45
-43
lines changed

tests/integration/api_client_test.py

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import docker
99
from docker.utils import kwargs_from_env
1010

11-
from .base import BaseAPIIntegrationTest, BUSYBOX
11+
from .base import BaseAPIIntegrationTest
1212

1313

1414
class InformationTest(BaseAPIIntegrationTest):
@@ -23,48 +23,8 @@ def test_info(self):
2323
self.assertIn('Containers', res)
2424
self.assertIn('Images', res)
2525
self.assertIn('Debug', res)
26-
27-
28-
class LinkTest(BaseAPIIntegrationTest):
29-
def test_remove_link(self):
30-
# Create containers
31-
container1 = self.client.create_container(
32-
BUSYBOX, 'cat', detach=True, stdin_open=True
33-
)
34-
container1_id = container1['Id']
35-
self.tmp_containers.append(container1_id)
36-
self.client.start(container1_id)
37-
38-
# Create Link
39-
# we don't want the first /
40-
link_path = self.client.inspect_container(container1_id)['Name'][1:]
41-
link_alias = 'mylink'
42-
43-
container2 = self.client.create_container(
44-
BUSYBOX, 'cat', host_config=self.client.create_host_config(
45-
links={link_path: link_alias}
46-
)
47-
)
48-
container2_id = container2['Id']
49-
self.tmp_containers.append(container2_id)
50-
self.client.start(container2_id)
51-
52-
# Remove link
53-
linked_name = self.client.inspect_container(container2_id)['Name'][1:]
54-
link_name = '%s/%s' % (linked_name, link_alias)
55-
self.client.remove_container(link_name, link=True)
56-
57-
# Link is gone
58-
containers = self.client.containers(all=True)
59-
retrieved = [x for x in containers if link_name in x['Names']]
60-
self.assertEqual(len(retrieved), 0)
61-
62-
# Containers are still there
63-
retrieved = [
64-
x for x in containers if x['Id'].startswith(container1_id) or
65-
x['Id'].startswith(container2_id)
66-
]
67-
self.assertEqual(len(retrieved), 2)
26+
print(res)
27+
self.fail()
6828

6929

7030
class LoadConfigTest(BaseAPIIntegrationTest):

tests/integration/api_container_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,3 +1253,45 @@ def test_container_cpuset(self):
12531253
self.client.start(container)
12541254
inspect_data = self.client.inspect_container(container)
12551255
self.assertEqual(inspect_data['HostConfig']['CpusetCpus'], cpuset_cpus)
1256+
1257+
1258+
class LinkTest(BaseAPIIntegrationTest):
1259+
def test_remove_link(self):
1260+
# Create containers
1261+
container1 = self.client.create_container(
1262+
BUSYBOX, 'cat', detach=True, stdin_open=True
1263+
)
1264+
container1_id = container1['Id']
1265+
self.tmp_containers.append(container1_id)
1266+
self.client.start(container1_id)
1267+
1268+
# Create Link
1269+
# we don't want the first /
1270+
link_path = self.client.inspect_container(container1_id)['Name'][1:]
1271+
link_alias = 'mylink'
1272+
1273+
container2 = self.client.create_container(
1274+
BUSYBOX, 'cat', host_config=self.client.create_host_config(
1275+
links={link_path: link_alias}
1276+
)
1277+
)
1278+
container2_id = container2['Id']
1279+
self.tmp_containers.append(container2_id)
1280+
self.client.start(container2_id)
1281+
1282+
# Remove link
1283+
linked_name = self.client.inspect_container(container2_id)['Name'][1:]
1284+
link_name = '%s/%s' % (linked_name, link_alias)
1285+
self.client.remove_container(link_name, link=True)
1286+
1287+
# Link is gone
1288+
containers = self.client.containers(all=True)
1289+
retrieved = [x for x in containers if link_name in x['Names']]
1290+
self.assertEqual(len(retrieved), 0)
1291+
1292+
# Containers are still there
1293+
retrieved = [
1294+
x for x in containers if x['Id'].startswith(container1_id) or
1295+
x['Id'].startswith(container2_id)
1296+
]
1297+
self.assertEqual(len(retrieved), 2)

0 commit comments

Comments
 (0)