Coverage for rfpy/buyer/webapp.py: 100%
20 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-24 10:52 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-24 10:52 +0000
1import logging
2from typing import Callable
4import webob.exc
6from rfpy.web.base import WSGIApp
7from rfpy.model.humans import OrganisationType
8from rfpy.suxint import Sux
10log = logging.getLogger(__name__)
13buyer_sux = Sux("rfpy.api.endpoints", "rfpy.adaptors", api_name="PostRFP Buyer API")
16class BuyerApp(WSGIApp):
17 routes: dict[str, Callable] = {}
19 def validate_user(self, request) -> None:
20 user = request.user
21 if user.organisation.type not in (
22 OrganisationType.CONSULTANT,
23 OrganisationType.BUYER,
24 ):
25 log.warning(
26 "Denying access to %s for %s (Not Consulant or Buyer user)",
27 request.url,
28 user,
29 )
30 raise webob.exc.HTTPForbidden("URL forbidden for Respondent users")
32 def build_sux(self) -> None:
33 self.sux_instance = buyer_sux
36@BuyerApp.route("/raise-check")
37def raise_check(request) -> None:
38 """Check exception handling"""
39 raise Exception("Raised test exception to check exception handling")