From 8156df60dd5ee4fe2d41c393af7c117f67e654d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= <mickael.misbach@orbitalize.com>
Date: Fri, 8 Dec 2023 16:20:50 +0100
Subject: [PATCH] [mock_uss/f3548] Add check for priority allowed in locality
 and remove high-priority intents for f3548_self_contained (#389)

* [mock_uss/f3548] add check for priority allowed in locality; use CHE locality in CI

* revert default mock USS locality

* setup f3548 suite for optional preemption flight intents

* revert mistake

* revert 2nd mistake
---
 monitoring/mock_uss/f3548v21/flight_planning.py        | 10 ++++++++++
 .../configurations/dev/f3548_self_contained.yaml       |  8 --------
 monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/monitoring/mock_uss/f3548v21/flight_planning.py b/monitoring/mock_uss/f3548v21/flight_planning.py
index 0c5f89c923..3e0fb1484f 100644
--- a/monitoring/mock_uss/f3548v21/flight_planning.py
+++ b/monitoring/mock_uss/f3548v21/flight_planning.py
@@ -420,6 +420,16 @@ def check_op_intent(
             f"Operational intent state transition from {state_transition_from} to {state_transition_to} is invalid"
         )
 
+    # Check the priority is allowed in the locality
+    priority = new_flight.op_intent.details.priority
+    if (
+        priority > locality.highest_priority()
+        or priority <= locality.lowest_bound_priority()
+    ):
+        raise PlanningError(
+            f"Operational intent priority {priority} is outside the bounds of the locality priority range (]{locality.lowest_bound_priority()},{locality.highest_priority()}])"
+        )
+
     if new_flight.op_intent.reference.state in (
         f3548_v21.OperationalIntentState.Accepted,
         f3548_v21.OperationalIntentState.Activated,
diff --git a/monitoring/uss_qualifier/configurations/dev/f3548_self_contained.yaml b/monitoring/uss_qualifier/configurations/dev/f3548_self_contained.yaml
index 179d1715fa..46eef3d548 100644
--- a/monitoring/uss_qualifier/configurations/dev/f3548_self_contained.yaml
+++ b/monitoring/uss_qualifier/configurations/dev/f3548_self_contained.yaml
@@ -15,7 +15,6 @@ v1:
         resources:
           flight_planners: flight_planners
           conflicting_flights: conflicting_flights
-          priority_preemption_flights: priority_preemption_flights
           invalid_flight_intents: invalid_flight_intents
           non_conflicting_flights: non_conflicting_flights
           dss: dss
@@ -57,13 +56,6 @@ v1:
             file:
               path: file://./test_data/che/flight_intents/conflicting_flights.yaml
 
-        # Details of priority-preemption flights (used in nominal planning priority scenario)
-        priority_preemption_flights:
-          resource_type: resources.flight_planning.FlightIntentsResource
-          specification:
-            file:
-              path: test_data.che.flight_intents.conflicting_flights
-
         # Details of flights with invalid operational intents (used in flight intent validation scenario)
         invalid_flight_intents:
           resource_type: resources.flight_planning.FlightIntentsResource
diff --git a/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml b/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml
index 99e1f60fe4..408b3565e1 100644
--- a/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml
+++ b/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml
@@ -4,7 +4,7 @@ resources:
   dss: resources.astm.f3548.v21.DSSInstanceResource
   dss_instances: resources.astm.f3548.v21.DSSInstancesResource?
   conflicting_flights: resources.flight_planning.FlightIntentsResource
-  priority_preemption_flights: resources.flight_planning.FlightIntentsResource
+  priority_preemption_flights: resources.flight_planning.FlightIntentsResource?
   invalid_flight_intents: resources.flight_planning.FlightIntentsResource
   non_conflicting_flights: resources.flight_planning.FlightIntentsResource
   nominal_planning_selector: resources.flight_planning.FlightPlannerCombinationSelectorResource?