Skip to content

Commit

Permalink
[uss_qualifier] Remove begin and end test step from reusable function…
Browse files Browse the repository at this point in the history
…s in test_steps (#417)

Remove begin and end test step from reusable functions in test_steps
  • Loading branch information
BenjaminPelletier authored Dec 18, 2023
1 parent 0e68bc2 commit f4a9390
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def _setup(self):
)
self.end_test_step()

set_uss_available(
self, "Restore virtual USS availability", self.dss, self.uss_qualifier_sub
)
self.begin_test_step("Restore virtual USS availability")
set_uss_available(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

self.begin_test_step("Clear operational intents created by virtual USS")
self._clear_op_intents()
Expand Down Expand Up @@ -216,9 +216,9 @@ def _plan_flight_conflict_planned(self):
)

# Declare virtual USS as down at DSS test step
set_uss_down(
self, "Declare virtual USS as down at DSS", self.dss, self.uss_qualifier_sub
)
self.begin_test_step("Declare virtual USS as down at DSS")
set_uss_down(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

# Tested USS attempts to plan Flight 1 test step
with OpIntentValidator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ def _plan_flight_conflict_activated(self) -> OperationalIntentReference:
)

# Declare virtual USS as down at DSS test step
set_uss_down(
self, "Declare virtual USS as down at DSS", self.dss, self.uss_qualifier_sub
)
self.begin_test_step("Declare virtual USS as down at DSS")
set_uss_down(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

# Tested USS attempts to plan high-priority flight 2 test step
with OpIntentValidator(
Expand Down Expand Up @@ -121,12 +121,9 @@ def _plan_flight_conflict_activated(self) -> OperationalIntentReference:
validator.expect_not_shared()

# Restore virtual USS availability at DSS test step
set_uss_available(
self,
"Restore virtual USS availability at DSS",
self.dss,
self.uss_qualifier_sub,
)
self.begin_test_step("Restore virtual USS availability at DSS")
set_uss_available(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

return oi_ref

Expand All @@ -140,9 +137,9 @@ def _plan_flight_conflict_nonconforming(
)

# Declare virtual USS as down at DSS test step
set_uss_down(
self, "Declare virtual USS as down at DSS", self.dss, self.uss_qualifier_sub
)
self.begin_test_step("Declare virtual USS as down at DSS")
set_uss_down(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

# Tested USS attempts to plan high-priority flight 2 test step
with OpIntentValidator(
Expand Down Expand Up @@ -171,12 +168,9 @@ def _plan_flight_conflict_nonconforming(
validator.expect_not_shared()

# Restore virtual USS availability at DSS test step
set_uss_available(
self,
"Restore virtual USS availability at DSS",
self.dss,
self.uss_qualifier_sub,
)
self.begin_test_step("Restore virtual USS availability at DSS")
set_uss_available(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

return oi_ref

Expand All @@ -188,9 +182,9 @@ def _plan_flight_conflict_contingent(self, oi_ref: OperationalIntentReference):
)

# Declare virtual USS as down at DSS test step
set_uss_down(
self, "Declare virtual USS as down at DSS", self.dss, self.uss_qualifier_sub
)
self.begin_test_step("Declare virtual USS as down at DSS")
set_uss_down(self, self.dss, self.uss_qualifier_sub)
self.end_test_step()

# Tested USS attempts to plan high-priority flight 2 test step
with OpIntentValidator(
Expand Down
10 changes: 2 additions & 8 deletions monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,18 +580,16 @@ def __eq__(self, other):

def set_uss_available(
scenario: TestScenarioType,
test_step: str,
dss: DSSInstance,
uss_sub: str,
) -> str:
"""Set the USS availability to 'Available'.
This function implements the test step described in set_uss_available.md.
This function implements the test step fragment described in set_uss_available.md.
Returns:
The new version of the USS availability.
"""
scenario.begin_test_step(test_step)
availability_version, avail_query = dss.set_uss_availability(
uss_sub,
True,
Expand All @@ -606,24 +604,21 @@ def set_uss_available(
details=f"DSS responded code {avail_query.status_code}; error message: {avail_query.error_message}",
query_timestamps=[avail_query.request.timestamp],
)
scenario.end_test_step()
return availability_version


def set_uss_down(
scenario: TestScenarioType,
test_step: str,
dss: DSSInstance,
uss_sub: str,
) -> str:
"""Set the USS availability to 'Down'.
This function implements the test step described in set_uss_down.md.
This function implements the test step fragment described in set_uss_down.md.
Returns:
The new version of the USS availability.
"""
scenario.begin_test_step(test_step)
availability_version, avail_query = dss.set_uss_availability(
uss_sub,
False,
Expand All @@ -638,5 +633,4 @@ def set_uss_down(
details=f"DSS responded code {avail_query.status_code}; error message: {avail_query.error_message}",
query_timestamps=[avail_query.request.timestamp],
)
scenario.end_test_step()
return availability_version

0 comments on commit f4a9390

Please sign in to comment.