def test_destroy_capsule_by_uuid(self, mock_db_inst, mock_delete, mock_write, mock_read): mock_db_inst.return_value = etcdapi.get_backend() mock_read.side_effect = etcd.EtcdKeyNotFound capsule = utils.create_test_capsule(context=self.context) mock_read.side_effect = lambda *args: FakeEtcdResult(capsule.as_dict()) dbapi.destroy_capsule(self.context, capsule.uuid) mock_delete.assert_called_once_with('/capsules/%s' % capsule.uuid)
def destroy(self, context=None): """Delete the Container from the DB. :param context: Security context. NOTE: This should only be used internally by the indirection_api. Unfortunately, RPC requires context as the first argument, even though we don't use it. A context should be set when instantiating the object, e.g.: Capsule(context) """ dbapi.destroy_capsule(context, self.uuid) self.obj_reset_changes()
def test_destroy_capsule_by_uuid(self): capsule = utils.create_test_capsule(context=self.context) dbapi.destroy_capsule(self.context, capsule.uuid) self.assertRaises(exception.CapsuleNotFound, dbapi.get_capsule_by_uuid, self.context, capsule.uuid)