'Ensure volume types can be created and deleted.'

def test_volume_type_create_then_destroy(self):

    project_id = fake.PROJECT_ID
    prev_all_vtypes = volume_types.get_all_types(self.ctxt)
    type_ref = volume_types.create(self.ctxt, self.vol_type1_name, self.vol_type1_specs, description=self.vol_type1_description, projects=[project_id], is_public=False)
    new = volume_types.get_volume_type_by_name(self.ctxt, self.vol_type1_name)
    self.assertEqual(self.vol_type1_description, new['description'])
    for (k, v) in self.vol_type1_specs.items():
        self.assertEqual(v, new['extra_specs'][k], 'one    of    fields    does    not    match')
    new_all_vtypes = volume_types.get_all_types(self.ctxt)
    self.assertEqual((len(prev_all_vtypes) + 1), len(new_all_vtypes), 'drive    type    was    not    created')
    vol_type_access = db.volume_type_access_get_all(self.ctxt, type_ref['id'])
    self.assertIn(project_id, [a.project_id for a in vol_type_access])
    new_type_name = (self.vol_type1_name + '_updated')
    new_type_desc = (self.vol_type1_description + '_updated')
    volume_types.update(self.ctxt, type_ref.id, new_type_name, new_type_desc)
    type_ref_updated = volume_types.get_volume_type(self.ctxt, type_ref.id)
    self.assertEqual(new_type_name, type_ref_updated['name'])
    self.assertEqual(new_type_desc, type_ref_updated['description'])
    volume_types.destroy(self.ctxt, type_ref['id'])
    new_all_vtypes = volume_types.get_all_types(self.ctxt)
    self.assertEqual(prev_all_vtypes, new_all_vtypes, 'drive    type    was    not    deleted')
    vol_type_access = db_api._volume_type_access_query(self.ctxt).filter_by(volume_type_id=type_ref['id']).all()
    self.assertFalse(vol_type_access)
