Exemple #1
0
    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
Exemple #2
0
 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')
Exemple #3
0
 def test_net(self):
     net = Net('host')
     self.assertEqual(net.id, 'host')
     self.assertEqual(net.mode, 'host')
     self.assertEqual(net.service_name, None)
Exemple #4
0
 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()
Exemple #5
0
 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()