'Test delete volume metadata with different metadata type.'

def test_delete_volume_metadata_with_metatype(self):

    test_meta1 = {'fake_key1': 'fake_value1', 'fake_key2': 'fake_value2'}
    test_meta2 = {'fake_key1': 'fake_value1'}
    FAKE_METADATA_TYPE = enum.Enum('METADATA_TYPES', 'fake_type')
    volume = tests_utils.create_volume(self.context, metadata=test_meta1, **self.volume_params)
    volume_id = volume['id']
    self.volume.create_volume(self.context, volume)
    self.volume_api.delete_volume_metadata(self.context, volume, 'fake_key2', common.METADATA_TYPES.user)
    self.assertEqual(test_meta2, db.volume_metadata_get(self.context, volume_id))
    result_meta = self.volume_api.update_volume_metadata(self.context, volume, test_meta1, False, common.METADATA_TYPES.image)
    self.assertEqual(test_meta1, result_meta)
    self.volume_api.delete_volume_metadata(self.context, volume, 'fake_key2', common.METADATA_TYPES.image)
    rows = db.volume_glance_metadata_get(self.context, volume_id)
    result = {}
    for row in rows:
        result[row['key']] = row['value']
    self.assertEqual(test_meta2, result)
    self.assertRaises(exception.InvalidMetadataType, self.volume_api.delete_volume_metadata, self.context, volume, 'fake_key1', FAKE_METADATA_TYPE.fake_type)
