def get_qos_specs_by_name(context, name): """Retrieves single qos specs by name.""" if name is None: msg = _("name cannot be None") raise exception.InvalidQoSSpecs(reason=msg) return db.qos_specs_get_by_name(context, name)
def test_qos_specs_get_by_name(self): name = str(int(time.time())) value = dict(consumer="front-end", foo="Foo", bar="Bar") specs_id = self._create_qos_specs(name, value) specs = db.qos_specs_get_by_name(self.ctxt, name) del value["consumer"] expected = {"name": name, "id": specs_id, "consumer": "front-end", "specs": value} self.assertDictMatch(specs, expected)
def test_qos_specs_get_by_name(self): name = str(int(time.time())) value = dict(consumer='front-end', foo='Foo', bar='Bar') specs_id = self._create_qos_specs(name, value) specs = db.qos_specs_get_by_name(self.ctxt, name) value.update(dict(id=specs_id)) expected = {name: value} self.assertDictMatch(specs, expected)
def test_qos_specs_create(self): # If there is qos specs with the same name exists, # a QoSSpecsExists exception will be raised. name = "QoSSpecsCreationTest" self._create_qos_specs(name) self.assertRaises(exception.QoSSpecsExists, db.qos_specs_create, self.ctxt, dict(name=name)) specs_id = self._create_qos_specs("NewName") query_id = db.qos_specs_get_by_name(self.ctxt, "NewName")["id"] self.assertEqual(specs_id, query_id)
def test_qos_specs_create(self): # If there is qos specs with the same name exists, # a QoSSpecsExists exception will be raised. name = 'QoSSpecsCreationTest' self._create_qos_specs(name) self.assertRaises(exception.QoSSpecsExists, db.qos_specs_create, self.ctxt, dict(name=name)) specs_id = self._create_qos_specs('NewName') query_id = db.qos_specs_get_by_name(self.ctxt, 'NewName')['id'] self.assertEqual(specs_id, query_id)
def test_qos_specs_get_by_name(self): name = str(int(time.time())) value = dict(consumer='front-end', foo='Foo', bar='Bar') specs_id = self._create_qos_specs(name, value) specs = db.qos_specs_get_by_name(self.ctxt, name) del value['consumer'] expected = {'name': name, 'id': specs_id, 'consumer': 'front-end', 'specs': value} self.assertDictMatch(expected, specs)
def test_qos_specs_get_by_name(self): name = str(int(time.time())) value = dict(consumer='front-end', foo='Foo', bar='Bar') specs_id = self._create_qos_specs(name, value) specs = db.qos_specs_get_by_name(self.ctxt, name) del value['consumer'] expected = {'name': name, 'id': specs_id, 'consumer': 'front-end', 'specs': value} self.assertDictMatch(specs, expected)
def test_qos_specs_create(self): # If there is qos specs with the same name exists, # a QoSSpecsExists exception will be raised. name = 'QoSSpecsCreationTest' self._create_qos_specs(name) self.assertRaises(exception.QoSSpecsExists, db.qos_specs_create, self.ctxt, dict(name=name)) specs_id = self._create_qos_specs('NewName') query_id = db.qos_specs_get_by_name( self.ctxt, 'NewName')['NewName']['id'] self.assertEquals(specs_id, query_id)