Coverage for rfpy/buyer/webapp.py: 100%

19 statements  

« prev     ^ index     » next       coverage.py v7.0.1, created at 2022-12-31 16:00 +0000

1import logging 

2 

3import webob.exc 

4 

5from rfpy.web.base import WSGIApp 

6from rfpy.model.humans import OrganisationType 

7from rfpy.suxint import Sux 

8 

9log = logging.getLogger(__name__) 

10 

11 

12buyer_sux = Sux('rfpy.api.endpoints', 'rfpy.adaptors', api_name='PostRFP Buyer API') 

13 

14 

15class BuyerApp(WSGIApp): 

16 

17 routes = {} 

18 

19 def validate_user(self, request): 

20 user = request.user 

21 if user.organisation.type not in (OrganisationType.CONSULTANT, 

22 OrganisationType.BUYER): 

23 log.warning('Denying access to %s for %s (Not Consulant or Buyer user)', 

24 request.url, user) 

25 raise webob.exc.HTTPForbidden('URL forbidden for Respondent users') 

26 

27 def build_sux(self): 

28 self.sux_instance = buyer_sux 

29 

30 

31@BuyerApp.route('/raise-check') 

32def raise_check(request): 

33 '''Check exception handling''' 

34 raise Exception('Raised test exception to check exception handling')