MCPcopy Index your code
hub / github.com/docker/docker-py / test_port

Method test_port

tests/integration/api_container_test.py:1098–1132  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1096
1097class PortTest(BaseAPIIntegrationTest):
1098 def test_port(self):
1099 port_bindings = {
1100 '1111': ('127.0.0.1', '4567'),
1101 '2222': ('127.0.0.1', '4568'),
1102 '3333/udp': ('127.0.0.1', '4569'),
1103 }
1104 ports = [
1105 1111,
1106 2222,
1107 (3333, 'udp'),
1108 ]
1109
1110 container = self.client.create_container(
1111 TEST_IMG, ['sleep', '60'], ports=ports,
1112 host_config=self.client.create_host_config(
1113 port_bindings=port_bindings, network_mode='bridge'
1114 )
1115 )
1116 id = container['Id']
1117
1118 self.client.start(container)
1119
1120 # Call the port function on each biding and compare expected vs actual
1121 for port in port_bindings:
1122 port, _, protocol = port.partition('/')
1123 actual_bindings = self.client.port(container, port)
1124 port_binding = actual_bindings.pop()
1125
1126 ip, host_port = port_binding['HostIp'], port_binding['HostPort']
1127
1128 port_binding = port if not protocol else f"{port}/{protocol}"
1129 assert ip == port_bindings[port_binding][0]
1130 assert host_port == port_bindings[port_binding][1]
1131
1132 self.client.kill(id)
1133
1134
1135class ContainerTopTest(BaseAPIIntegrationTest):

Callers

nothing calls this directly

Calls 5

create_containerMethod · 0.80
create_host_configMethod · 0.80
portMethod · 0.80
startMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected