49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from fastapi import APIRouter, Request, Response
|
|
|
|
from ApiServices.TemplateService.events.template.event import template_event_cluster
|
|
|
|
test_template_route = APIRouter(prefix="/test", tags=["Test"])
|
|
|
|
|
|
@test_template_route.get(
|
|
path="/template",
|
|
description="Test Template Route",
|
|
operation_id="bb20c8c6-a289-4cab-9da7-34ca8a36c8e5",
|
|
)
|
|
def test_template(request: Request, response: Response):
|
|
"""
|
|
Test Template Route
|
|
"""
|
|
event_cluster_matched = template_event_cluster.match_event(
|
|
event_keys=[
|
|
"3f510dcf-9f84-4eb9-b919-f582f30adab1",
|
|
"9f403034-deba-4e1f-b43e-b25d3c808d39",
|
|
"b8ec6e64-286a-4f60-8554-7a3865454944",
|
|
]
|
|
)
|
|
response.headers["X-Header"] = "Test Header GET"
|
|
if runner_callable := event_cluster_matched.example_callable():
|
|
return runner_callable
|
|
raise ValueError("Event key not found or multiple matches found")
|
|
|
|
|
|
@test_template_route.post(
|
|
path="/template",
|
|
description="Test Template Route with Post Method",
|
|
)
|
|
def test_template_post(request: Request, response: Response):
|
|
"""
|
|
Test Template Route with Post Method
|
|
"""
|
|
event_cluster_matched = template_event_cluster.match_event(
|
|
event_keys=[
|
|
"3f510dcf-9f84-4eb9-b919-f582f30adab1",
|
|
"9f403034-deba-4e1f-b43e-b25d3c808d39",
|
|
"b8ec6e64-286a-4f60-8554-7a3865454944",
|
|
]
|
|
)
|
|
response.headers["X-Header"] = "Test Header POST"
|
|
if runner_callable := event_cluster_matched.example_callable():
|
|
return runner_callable
|
|
raise ValueError("Event key not found or multiple matches found")
|