Skip to content

Commit

Permalink
[uss_qualifier/scenarios/utm/data_exchange_validation] Fix interpolat…
Browse files Browse the repository at this point in the history
…ion of operation path (#829)
  • Loading branch information
mickmis authored Nov 6, 2024
1 parent 4f6ff0f commit 75574c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ def _plan_successfully_test_case(self, times: Dict[TimeDuringTest, Time]):
op_id=OperationID.GetOperationalIntentDetails,
direction=QueryDirection.Incoming,
since=flight_1_planning_time,
query_params={"entity_id": flight_2_oi_ref.id},
query_params=dict(
entityid=flight_2_oi_ref.id,
),
)
with self.check(
"Expect GET request when no notification",
Expand Down Expand Up @@ -337,7 +339,9 @@ def _plan_unsuccessfully_test_case(self, times: Dict[TimeDuringTest, Time]):
op_id=OperationID.GetOperationalIntentDetails,
direction=QueryDirection.Incoming,
since=flight_1_planning_time,
query_params={"entity_id": flight_2_oi_ref.id},
query_params=dict(
entityid=flight_2_oi_ref.id,
),
)
with self.check(
"Expect GET request when no notification",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ def mock_uss_interactions(
query_params: Optional[Dict[str, str]] = None,
is_applicable: Optional[Callable[[Interaction], bool]] = None,
) -> Tuple[List[Interaction], Query]:
"""Determine if mock_uss recorded an interaction for the specified operation in the specified direction."""
"""
Determine if mock_uss recorded an interaction for the specified operation in the specified direction.
Raises:
KeyError: if query_params contains a non-existing parameter
IndexError: if query_params is missing a parameter
"""
with scenario.check(
"Mock USS interactions logs retrievable", [mock_uss.participant_id]
) as check:
Expand All @@ -142,12 +147,9 @@ def mock_uss_interactions(

op = api.OPERATIONS[op_id]

op_path = op.path
if query_params is None:
query_params = {}
for m in re.findall(r"\{[^}]+\}", op_path):
param_name = m[1:-1]
op_path = op_path.replace(m, query_params.get(param_name, r"[^/]+"))
query_params = {} # avoid linting error due to immutable default argument
op_path = op.path.format(**query_params) # raises KeyError, IndexError

if is_applicable is None:
is_applicable = lambda i: True
Expand Down

0 comments on commit 75574c6

Please sign in to comment.