def test_get_capsule_by_uuid(self, mock_write, mock_read): mock_read.side_effect = etcd.EtcdKeyNotFound capsule = utils.create_test_capsule(context=self.context) mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict()) res = dbapi.get_capsule_by_uuid(self.context, capsule.uuid) self.assertEqual(capsule.id, res.id) self.assertEqual(capsule.uuid, res.uuid)
def get_by_uuid(cls, context, uuid): """Find a capsule based on uuid and return a :class:`Capsule` object. :param uuid: the uuid of a capsule. :param context: Security context :returns: a :class:`Capsule` object. """ db_capsule = dbapi.get_capsule_by_uuid(context, uuid) capsule = Capsule._from_db_object(cls(context), db_capsule) return capsule
def test_get_capsule_by_uuid(self): capsule = utils.create_test_capsule(context=self.context) res = dbapi.get_capsule_by_uuid(self.context, capsule.uuid) self.assertEqual(capsule.id, res.id) self.assertEqual(capsule.uuid, res.uuid)