Skip to content

Commit

Permalink
feat: add api test event pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
maxhoheiser committed Apr 25, 2024
1 parent 002c2d6 commit 08b80f9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions localstack/services/events/provider_v2.py
Expand Up @@ -46,6 +46,7 @@
TargetId,
TargetIdList,
TargetList,
TestEventPatternResponse,
)
from localstack.aws.api.events import EventBus as ApiTypeEventBus
from localstack.aws.api.events import Rule as ApiTypeRule
Expand Down Expand Up @@ -341,6 +342,19 @@ def put_rule(
response = PutRuleResponse(RuleArn=rule_service.arn)
return response

@handler("TestEventPattern")
def test_event_pattern(
self, context: RequestContext, event_pattern: EventPattern, event: str, **kwargs
) -> TestEventPatternResponse:
"""Test event pattern uses EventBridge event pattern matching:
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html
"""
event_pattern_dict = json.loads(event_pattern)
event_dict = json.loads(event)
result = matches_event(event_pattern_dict, event_dict)

return TestEventPatternResponse(Result=result)

#########
# Targets
#########
Expand Down

0 comments on commit 08b80f9

Please sign in to comment.