Coverage for chalicelib/utils/contextual_validators.py: 0%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-10 12:56 +0000
1import schemas
2from fastapi import HTTPException, Depends
3from or_dependencies import OR_context
6def validate_contextual_payload(
7 item: schemas.SessionsSearchPayloadSchema,
8 context: schemas.CurrentContext = Depends(OR_context)
9) -> schemas.SessionsSearchPayloadSchema:
10 if context.project.platform == "web":
11 for e in item.events:
12 if e.name in [schemas.EventType.CLICK_MOBILE,
13 schemas.EventType.INPUT_MOBILE,
14 schemas.EventType.VIEW_MOBILE,
15 schemas.EventType.CUSTOM_MOBILE,
16 schemas.EventType.REQUEST_MOBILE,
17 schemas.EventType.ERROR_MOBILE,
18 schemas.EventType.SWIPE_MOBILE]:
19 raise HTTPException(status_code=422,
20 detail=f"Mobile event '{e.name}' not supported for web project")
21 else:
22 for e in item.events:
23 if e.name in [schemas.EventType.CLICK,
24 schemas.EventType.INPUT,
25 schemas.EventType.LOCATION,
26 schemas.EventType.CUSTOM,
27 schemas.EventType.REQUEST,
28 schemas.EventType.REQUEST_DETAILS,
29 schemas.EventType.GRAPHQL,
30 schemas.EventType.STATE_ACTION,
31 schemas.EventType.ERROR,
32 schemas.EventType.TAG]:
33 raise HTTPException(status_code=422,
34 detail=f"Web event '{e.name}' not supported for mobile project")
36 return item