'Test volume create from source with types including mistmatch.'

@mock.patch('cinder.volume.flows.api.create_volume.get_flow')
def test_create_volume_from_source_with_types(self, _get_flow):

    volume_api = cinder.volume.api.API()
    foo_type = fake_volume.fake_volume_type_obj(self.context, id=fake.VOLUME_TYPE_ID, name='foo', extra_specs={'volume_backend_name': 'dev_1'})
    biz_type = fake_volume.fake_volume_type_obj(self.context, id=fake.VOLUME_TYPE2_ID, name='biz', extra_specs={'volume_backend_name': 'dev_2'})
    source_vol = fake_volume.fake_volume_obj(self.context, id=fake.VOLUME_ID, status='available', volume_size=0, volume_type_id=biz_type.id)
    source_vol.volume_type = biz_type
    self.assertRaises(exception.InvalidInput, volume_api.create, self.context, size=1, name='fake_name', description='fake_desc', volume_type=foo_type, source_volume=source_vol)
    source_vol.volume_type_id = None
    source_vol.volume_type = None
    self.assertRaises(exception.InvalidInput, volume_api.create, self.context, size=1, name='fake_name', description='fake_desc', volume_type=foo_type, source_volume=source_vol)
    source_vol.volume_type_id = biz_type.id
    source_vol.volume_type = biz_type
    volume_api.create(self.context, size=1, name='fake_name', description='fake_desc', volume_type=biz_type, source_volume=source_vol)
