Coverage for model/test.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-11-05 04:22 +0000

1from flask import Blueprint, current_app, request 

2 

3from .auth import * 

4from .utils import * 

5 

6__all__ = ['test_api'] 

7 

8test_api = Blueprint('test_api', __name__) 

9 

10 

11@test_api.route('/') 

12@login_required 

13def test(user): 

14 return HTTPResponse(user.username) 

15 

16 

17@test_api.route('/role') 

18@identity_verify(0, 1, ...) 

19def role(user): 

20 return HTTPResponse(str(user.obj.role)) 

21 

22 

23@test_api.route('/log') 

24def log(): 

25 current_app.logger.debug('this is a DEBUG log') 

26 current_app.logger.info('this is a INFO log') 

27 current_app.logger.warning('this is a WARNING log') 

28 current_app.logger.error('this is a ERROR log') 

29 current_app.logger.critical('this is a CRITICAL log') 

30 return HTTPResponse('check the log') 

31 

32 

33@test_api.route('/header') 

34def check_header(): 

35 current_app.logger.debug(f'{request.headers}') 

36 return HTTPResponse('ok')