from functools import wraps
from flask import abort, current_app
from flask_login import current_user
from labsys.auth.models import Permission


def permission_required(permission):
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            if not current_user.can(permission) and \
                not current_app.config['TESTING'] == True:
                abort(403)
            return f(*args, **kwargs)
        return decorated_function
    return decorator


def admin_required(f):
    return permission_required(Permission.ADMINISTER) (f)

from functools import wraps
from flask import abort, current_app
from flask_login import current_user
from labsys.auth.models import Permission


def permission_required(permission):
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            if not current_user.can(permission):
                abort(403)
            return f(*args, **kwargs)
        return decorated_function
    return decorator


def admin_required(f):
    return permission_required(Permission.ADMINISTER)(f)

Remove test condition for permissions
:bug: Remove test condition for permissions

Otherwise I would not be able to test them properly

  from functools import wraps
  from flask import abort, current_app
  from flask_login import current_user
  from labsys.auth.models import Permission
  
  
  def permission_required(permission):
      def decorator(f):
          @wraps(f)
          def decorated_function(*args, **kwargs):
-             if not current_user.can(permission) and \
+             if not current_user.can(permission):
-                 not current_app.config['TESTING'] == True:
                  abort(403)
              return f(*args, **kwargs)
          return decorated_function
      return decorator
  
  
  def admin_required(f):
-     return permission_required(Permission.ADMINISTER) (f)
+     return permission_required(Permission.ADMINISTER)(f)
  
Remove test condition for permissions
## Code Before:
from functools import wraps
from flask import abort, current_app
from flask_login import current_user
from labsys.auth.models import Permission


def permission_required(permission):
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            if not current_user.can(permission) and \
                not current_app.config['TESTING'] == True:
                abort(403)
            return f(*args, **kwargs)
        return decorated_function
    return decorator


def admin_required(f):
    return permission_required(Permission.ADMINISTER) (f)

## Instruction:
Remove test condition for permissions
## Code After:
from functools import wraps
from flask import abort, current_app
from flask_login import current_user
from labsys.auth.models import Permission


def permission_required(permission):
    def decorator(f):
        @wraps(f)
        def decorated_function(*args, **kwargs):
            if not current_user.can(permission):
                abort(403)
            return f(*args, **kwargs)
        return decorated_function
    return decorator


def admin_required(f):
    return permission_required(Permission.ADMINISTER)(f)
