def test_project_up_with_custom_network(self): self.require_api_version('1.21') client = docker_client(version='1.21') network_name = 'composetest-custom' client.create_network(network_name) self.addCleanup(client.remove_network, network_name) web = self.create_service('web', net=Net(network_name)) project = Project('composetest', [web], client, use_networking=True) project.up() assert project.get_network() is None
def test_network_mode_host(self): service = self.create_service('web', net=Net('host')) container = create_and_start_container(service) self.assertEqual(container.get('HostConfig.NetworkMode'), 'host')
def test_net(self): net = Net('host') self.assertEqual(net.id, 'host') self.assertEqual(net.mode, 'host') self.assertEqual(net.service_name, None)
def test_uses_default_network_host(self): web = Service('web', project='test', image="alpine", net=Net('host')) project = Project('test', [web], None) assert not project.uses_default_network()
def test_uses_default_network_true(self): web = Service('web', project='test', image="alpine", net=Net('test')) db = Service('web', project='test', image="alpine", net=Net('other')) project = Project('test', [web, db], None) assert project.uses_default_network()