From ead7b728e3f027ef31949a1dafe9587f862fef4a Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Wed, 18 Dec 2024 22:13:36 +0000 Subject: [PATCH] Fix no-notification check logic --- .../expected_interactions_test_steps.py | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/data_exchange_validation/test_steps/expected_interactions_test_steps.py b/monitoring/uss_qualifier/scenarios/astm/utm/data_exchange_validation/test_steps/expected_interactions_test_steps.py index 9d00b7db64..169881f7bb 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/data_exchange_validation/test_steps/expected_interactions_test_steps.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/data_exchange_validation/test_steps/expected_interactions_test_steps.py @@ -85,33 +85,35 @@ def expect_no_interuss_post_interactions( direction_filter(QueryDirection.Incoming), ) - for interaction in interactions: - with scenario.check( - "Mock USS interaction can be parsed", [mock_uss.participant_id] - ) as check: - try: - req = PutOperationalIntentDetailsParameters( - ImplicitDict.parse( - interaction.query.request.json, - PutOperationalIntentDetailsParameters, + with scenario.check( + "Expect Notification not sent", [participant_id] + ) as no_notification_check: + for interaction in interactions: + with scenario.check( + "Mock USS interaction can be parsed", [mock_uss.participant_id] + ) as check: + try: + req = PutOperationalIntentDetailsParameters( + ImplicitDict.parse( + interaction.query.request.json, + PutOperationalIntentDetailsParameters, + ) + ) + except (ValueError, TypeError, KeyError) as e: + check.record_failed( + summary=f"Failed to parse request of a 'NotifyOperationalIntentDetailsChanged' interaction with mock_uss as a PutOperationalIntentDetailsParameters", + details=f"{str(e)}\nRequest: {interaction.query.request.json}\n\nStack trace:\n{e.stacktrace}", + query_timestamps=[query.request.timestamp], + ) + continue # low priority failure: continue checking interactions if one cannot be parsed + + op_intent_id = EntityID(req.operational_intent_id) + if op_intent_id not in shared_op_intent_ids: + no_notification_check.record_failed( + summary=f"Observed unexpected notification for operational intent ID {req.operational_intent_id}.", + details=f"Notification for operational intent ID {req.operational_intent_id} triggered by subscriptions {', '.join([sub.subscription_id for sub in req.subscriptions])} with timestamp {interaction.query.request.timestamp}.", + query_timestamps=[query.request.timestamp], ) - ) - except (ValueError, TypeError, KeyError) as e: - check.record_failed( - summary=f"Failed to parse request of a 'NotifyOperationalIntentDetailsChanged' interaction with mock_uss as a PutOperationalIntentDetailsParameters", - details=f"{str(e)}\nRequest: {interaction.query.request.json}\n\nStack trace:\n{e.stacktrace}", - query_timestamps=[query.request.timestamp], - ) - continue # low priority failure: continue checking interactions if one cannot be parsed - - with scenario.check("Expect Notification not sent", [participant_id]) as check: - op_intent_id = EntityID(req.operational_intent_id) - if op_intent_id not in shared_op_intent_ids: - check.record_failed( - summary=f"Observed unexpected notification for operational intent ID {req.operational_intent_id}.", - details=f"Notification for operational intent ID {req.operational_intent_id} triggered by subscriptions {', '.join([sub.subscription_id for sub in req.subscriptions])} with timestamp {interaction.query.request.timestamp}.", - query_timestamps=[query.request.timestamp], - ) def expect_uss_obtained_op_intent_details(