def test_merge_volume_bindings(self):
    options = [VolumeSpec.parse(v, True) for v in ['/host/volume:/host/volume:ro', '/host/rw/volume:/host/rw/volume', '/new/volume', '/existing/volume', '/dev/tmpfs']]
    self.mock_client.inspect_image.return_value = {'ContainerConfig': {'Volumes': {}}}
    previous_container = Container(self.mock_client, {'Id': 'cdefab', 'Image': 'ababab', 'Mounts': [{'Source': '/var/lib/docker/aaaaaaaa', 'Destination': '/existing/volume', 'Mode': '', 'RW': True, 'Name': 'existingvolume'}]}, has_been_inspected=True)
    expected = ['/host/volume:/host/volume:ro', '/host/rw/volume:/host/rw/volume:rw', 'existingvolume:/existing/volume:rw']
    (binds, affinity) = merge_volume_bindings(options, ['/dev/tmpfs'], previous_container, [])
    assert (sorted(binds) == sorted(expected))
    assert (affinity == {'affinity:container': '=cdefab'})
def test_merge_volume_bindings(self):
    options = [VolumeSpec.parse(v, True) for v in ['/host/volume:/host/volume:ro', '/host/rw/volume:/host/rw/volume', '/new/volume', '/existing/volume', '/dev/tmpfs']]
    self.mock_client.inspect_image.return_value = {'ContainerConfig': {'Volumes': {}}}
    previous_container = Container(self.mock_client, {'Id': 'cdefab', 'Image': 'ababab', 'Mounts': [{'Source': '/var/lib/docker/aaaaaaaa', 'Destination': '/existing/volume', 'Mode': , 'RW': True, 'Name': 'existingvolume'}]}, has_been_inspected=True)
    expected = ['/host/volume:/host/volume:ro', '/host/rw/volume:/host/rw/volume:rw', 'existingvolume:/existing/volume:rw']
    (binds, affinity) = merge_volume_bindings(options, ['/dev/tmpfs'], previous_container, [])
    assert (sorted(binds) == sorted(expected))
    assert (affinity == {'affinity:container': '=cdefab'})