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
« prev ^ index » next coverage.py v7.0.1, created at 2022-12-31 16:00 +0000
1import logging
3import webob.exc
5from rfpy.web.base import WSGIApp
6from rfpy.model.humans import OrganisationType
7from rfpy.suxint import Sux
9log = logging.getLogger(__name__)
12buyer_sux = Sux('rfpy.api.endpoints', 'rfpy.adaptors', api_name='PostRFP Buyer API')
15class BuyerApp(WSGIApp):
17 routes = {}
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')
27 def build_sux(self):
28 self.sux_instance = buyer_sux
31@BuyerApp.route('/raise-check')
32def raise_check(request):
33 '''Check exception handling'''
34 raise Exception('Raised test exception to check exception handling')