@classmethod
    def get_one(cls, fail_if_not_found=False, lock_for_update=False):
        q = db().query(cls.model)
        if lock_for_update:
            q = q.with_lockmode('update')

        res = q.first()

        if not res and fail_if_not_found:
            raise errors.ObjectNotFound(
                "Object '{0}' is not found in DB".format(cls.__name__)
            )
        return res
Test Model add, delete, edit
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/objects/master_node_settings.py/MasterNodeSettings.get_one--crossover with--dataset/ETHPy150Open dpgaspar/Flask-AppBuilder/flask_appbuilder/tests/test_mongoengine.py/FlaskTestCase.test_model_crud