def test_get_container_create_options_sets_affinity_with_binds(self):
    service = Service('foo', image='foo', client=self.mock_client)
    self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
    prev_container = mock.Mock(id='ababab', image_config={'ContainerConfig': {'Volumes': ['/data']}})

    def container_get(key):
        return {'Mounts': [{'Destination': '/data', 'Source': '/some/path', 'Name': 'abab1234'}]}.get(key, None)
    prev_container.get.side_effect = container_get
    opts = service._get_container_create_options({}, 1, previous_container=prev_container)
    assert (opts['environment'] == ['affinity:container==ababab'])
def test_get_container_create_options_sets_affinity_with_binds(self):
    service = Service('foo', image='foo', client=self.mock_client)
    self.mock_client.inspect_image.return_value = {'Id': 'abcd'}
    prev_container = mock.Mock(id='ababab', image_config={'ContainerConfig': {'Volumes': ['/data']}})

    def container_get(key):
        return {'Mounts': [{'Destination': '/data', 'Source': '/some/path', 'Name': 'abab1234'}]}.get(key, None)
    prev_container.get.side_effect = container_get
    opts = service._get_container_create_options({}, 1, previous_container=prev_container)
    assert (opts['environment'] == ['affinity:container==ababab'])