Exemplo n.º 1
0
    def test_config_dict_with_net_from_container(self):
        self.mock_client.inspect_image.return_value = {"Id": "abcd"}
        container = Container(self.mock_client, {"Id": "aaabbb", "Name": "/foo_1"})
        service = Service("foo", image="example.com/foo", client=self.mock_client, net=container)

        config_dict = service.config_dict()
        expected = {
            "image_id": "abcd",
            "options": {"image": "example.com/foo"},
            "links": [],
            "net": "aaabbb",
            "volumes_from": [],
        }
        self.assertEqual(config_dict, expected)
Exemplo n.º 2
0
    def test_config_dict(self):
        self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
        service = Service(
            'foo',
            image='example.com/foo',
            client=self.mock_client,
            net=ServiceNet(Service('other')),
            links=[(Service('one'), 'one')],
            volumes_from=[VolumeFromSpec(Service('two'), 'rw')])

        config_dict = service.config_dict()
        expected = {
            'image_id': 'abcd',
            'options': {'image': 'example.com/foo'},
            'links': [('one', 'one')],
            'net': 'other',
            'volumes_from': [('two', 'rw')],
        }
        self.assertEqual(config_dict, expected)
Exemplo n.º 3
0
    def test_config_dict_with_net_from_container(self):
        self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
        container = Container(
            self.mock_client,
            {'Id': 'aaabbb', 'Name': '/foo_1'})
        service = Service(
            'foo',
            image='example.com/foo',
            client=self.mock_client,
            net=container)

        config_dict = service.config_dict()
        expected = {
            'image_id': 'abcd',
            'options': {'image': 'example.com/foo'},
            'links': [],
            'net': 'aaabbb',
            'volumes_from': [],
        }
        self.assertEqual(config_dict, expected)
Exemplo n.º 4
0
    def test_config_dict(self):
        self.mock_client.inspect_image.return_value = {"Id": "abcd"}
        service = Service(
            "foo",
            image="example.com/foo",
            client=self.mock_client,
            net=ServiceNet(Service("other")),
            links=[(Service("one"), "one")],
            volumes_from=[VolumeFromSpec(Service("two"), "rw")],
        )

        config_dict = service.config_dict()
        expected = {
            "image_id": "abcd",
            "options": {"image": "example.com/foo"},
            "links": [("one", "one")],
            "net": "other",
            "volumes_from": ["two"],
        }
        self.assertEqual(config_dict, expected)
Exemplo n.º 5
0
    def test_config_dict_with_network_mode_from_container(self):
        self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
        container = Container(self.mock_client, {
            'Id': 'aaabbb',
            'Name': '/foo_1'
        })
        service = Service('foo',
                          image='example.com/foo',
                          client=self.mock_client,
                          network_mode=ContainerNetworkMode(container))

        config_dict = service.config_dict()
        expected = {
            'image_id': 'abcd',
            'options': {
                'image': 'example.com/foo'
            },
            'links': [],
            'networks': {},
            'net': 'aaabbb',
            'volumes_from': [],
        }
        assert config_dict == expected