@@ -1511,3 +1511,62 @@ def test_handler(payload):
1511
1511
],
1512
1512
}
1513
1513
assert result2 == expected_result2
1514
+
1515
+
1516
+ def test_subscribe_event_with_error_handling (lambda_context , mock_event ):
1517
+ """Test error handling during publish event processing."""
1518
+ # GIVEN a sample publish event
1519
+ mock_event ["info" ]["operation" ] = "SUBSCRIBE"
1520
+ del mock_event ["events" ] # SUBSCRIBE events are not supported
1521
+
1522
+ # GIVEN an AppSyncEventsResolver with a resolver that raises an exception
1523
+ app = AppSyncEventsResolver ()
1524
+
1525
+ @app .on_subscribe (path = "/default/*" )
1526
+ def test_handler ():
1527
+ raise ValueError ("Test error" )
1528
+
1529
+ # WHEN we resolve the event
1530
+ result = app .resolve (mock_event , lambda_context )
1531
+
1532
+ # THEN we should get an error response
1533
+ assert "error" in result
1534
+ assert "ValueError - Test error" in result ["error" ]
1535
+
1536
+ def test_subscribe_event_with_valid_return (lambda_context , mock_event ):
1537
+ """Test error handling during publish event processing."""
1538
+ # GIVEN a sample publish event
1539
+ mock_event ["info" ]["operation" ] = "SUBSCRIBE"
1540
+ del mock_event ["events" ] # SUBSCRIBE events are not supported
1541
+
1542
+ # GIVEN an AppSyncEventsResolver with a resolver that returns ok
1543
+ app = AppSyncEventsResolver ()
1544
+
1545
+ @app .on_publish (path = "/default/*" )
1546
+ def test_handler ():
1547
+ return 1
1548
+
1549
+ # WHEN we resolve the event
1550
+ result = app .resolve (mock_event , lambda_context )
1551
+
1552
+ # THEN we should get an error response
1553
+ assert result == 1
1554
+
1555
+ def test_subscribe_event_with_no_resolver (lambda_context , mock_event ):
1556
+ """Test error handling during publish event processing."""
1557
+ # GIVEN a sample publish event
1558
+ mock_event ["info" ]["operation" ] = "SUBSCRIBE"
1559
+ del mock_event ["events" ] # SUBSCRIBE events are not supported
1560
+
1561
+ # GIVEN an AppSyncEventsResolver with a resolver that returns ok
1562
+ app = AppSyncEventsResolver ()
1563
+
1564
+ @app .on_subscribe (path = "/test" )
1565
+ def test_handler ():
1566
+ return 1
1567
+
1568
+ # WHEN we resolve the event
1569
+ result = app .resolve (mock_event , lambda_context )
1570
+
1571
+ # THEN we should get an error response
1572
+ assert not result
0 commit comments