Skip to content

Commit

Permalink
Fix per PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
punamverma committed Dec 1, 2023
1 parent 2aa5f05 commit a44b49e
Show file tree
Hide file tree
Showing 9 changed files with 339 additions and 334 deletions.
22 changes: 12 additions & 10 deletions monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,9 @@ def get_full_op_intent(
op_intent_ref: OperationalIntentReference,
uss_participant_id: Optional[str] = None,
) -> Tuple[OperationalIntent, fetch.Query]:
url = f"{op_intent_ref.uss_base_url}/uss/v1/operational_intents/{op_intent_ref.id}"
query = fetch.query_and_describe(
self.client,
"GET",
url,
QueryType.F3548v21USSGetOperationalIntentDetails,
result, query = self.get_full_op_intent_without_validation(
op_intent_ref,
uss_participant_id,
scope=SCOPE_SC,
)
if query.status_code != 200:
result = None
Expand All @@ -101,19 +96,26 @@ def get_full_op_intent(
return result, query

def get_full_op_intent_without_validation(
self, op_intent_ref: OperationalIntentReference
self,
op_intent_ref: OperationalIntentReference,
uss_participant_id: Optional[str] = None,
) -> Tuple[Dict, fetch.Query]:
"""
GET OperationalIntent without validating, as invalid data expected for negative tests
Args:
op_intent_ref:
uss_participant_id:
Returns:
returns the response json when query is successful
"""
url = f"{op_intent_ref.uss_base_url}/uss/v1/operational_intents/{op_intent_ref.id}"
query = fetch.query_and_describe(
self.client, "GET", url, scope=SCOPE_SC, participant_id=self.participant_id
self.client,
"GET",
url,
QueryType.F3548v21USSGetOperationalIntentDetails,
uss_participant_id,
scope=SCOPE_SC,
)
result = None
if query.status_code == 200:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import Optional, Dict

from monitoring.monitorlib.clients.flight_planning.flight_info_template import (
FlightInfoTemplate,
)
from monitoring.monitorlib.temporal import TimeDuringTest, Time
from monitoring.monitorlib.temporal import TimeDuringTest
from urllib.parse import urlsplit
import arrow
from implicitdict import StringBasedDateTime
from datetime import datetime

from monitoring.monitorlib.temporal import Time
from monitoring.monitorlib.clients.flight_planning.client import FlightPlannerClient
Expand All @@ -26,7 +24,6 @@
MockUSSResource,
)
from monitoring.uss_qualifier.scenarios.astm.utm.data_exchange_validation.test_steps.invalid_op_test_steps import (
InvalidOpIntentSharingValidator,
plan_flight_intent_expect_failed,
)
from monitoring.uss_qualifier.scenarios.astm.utm.test_steps import OpIntentValidator
Expand Down Expand Up @@ -148,6 +145,8 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
):
times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_2 = self.flight_2.resolve(times)

planning_time = Time(arrow.utcnow().datetime)
with OpIntentValidator(
self,
self.control_uss_client,
Expand All @@ -164,17 +163,17 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(

flight_2_oi_ref = validator.expect_shared(flight_2)

precondition_no_post_interaction(
self,
self._precondition_no_post_interaction(
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
self.tested_uss_client.get_base_url(),
planning_time,
self._get_domain(self.tested_uss_client.get_base_url()),
"Precondition - check tested_uss has no subscription in flight 2 area",
)

times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_1 = self.flight_1.resolve(times)

planning_time = Time(arrow.utcnow().datetime)
with OpIntentValidator(
self,
self.tested_uss_client,
Expand All @@ -192,21 +191,19 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
flight_1,
)

control_uss_domain = "{0.scheme}://{0.netloc}/".format(
urlsplit(self.control_uss.base_url)
)
control_uss_domain = self.control_uss.base_url
expect_interuss_get_interactions(
self,
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
planning_time,
control_uss_domain,
flight_2_oi_ref.id,
"Validate flight2 GET interaction",
)
expect_interuss_post_interactions(
self,
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
planning_time,
control_uss_domain,
"Validate flight1 Notification sent to Control_uss",
)
Expand Down Expand Up @@ -235,7 +232,8 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(

additional_fields = {"behavior": behavior}

with InvalidOpIntentSharingValidator(
planning_time = Time(arrow.utcnow().datetime)
with OpIntentValidator(
self,
self.control_uss_client,
self.dss,
Expand All @@ -251,17 +249,17 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(
)
flight_2_oi_ref = validator.expect_shared_with_invalid_data(flight_info)

precondition_no_post_interaction(
self,
self._precondition_no_post_interaction(
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
self.tested_uss_client.get_base_url(),
planning_time,
self._get_domain(self.tested_uss_client.get_base_url()),
"Precondition - check tested_uss has no subscription in flight 2 area",
)

times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_1 = self.flight_1.resolve(times)
with InvalidOpIntentSharingValidator(
planning_time = Time(arrow.utcnow().datetime)
with OpIntentValidator(
self,
self.tested_uss_client,
self.dss,
Expand All @@ -276,21 +274,19 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(
)
validator.expect_not_shared()

control_uss_domain = "{0.scheme}://{0.netloc}/".format(
urlsplit(self.control_uss.base_url)
)
control_uss_domain = self.control_uss.base_url
expect_interuss_get_interactions(
self,
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
planning_time,
control_uss_domain,
flight_2_oi_ref.id,
"Validate flight 2 GET interaction",
)
expect_no_interuss_post_interactions(
self,
self.control_uss,
times[TimeDuringTest.TimeOfEvaluation],
planning_time,
control_uss_domain,
"Validate flight 1 Notification not sent to Control_uss",
)
Expand All @@ -299,6 +295,26 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(
self, "Delete Control_uss flight", self.control_uss_client, self.flight_2_id
)

def _precondition_no_post_interaction(
self,
mock_uss: MockUSSClient,
st: StringBasedDateTime,
posted_to_url: str,
test_step: str,
):
self.begin_test_step(test_step)

mock_uss_sent_notification = precondition_no_post_interaction(
self, mock_uss, st, posted_to_url
)
if mock_uss_sent_notification:
msg = f"As a precondition for the scenario tests, there should have been no post made to {posted_to_url}"
raise ScenarioCannotContinueError(msg)
self.end_test_step()

def _get_domain(self, url):
return "{0.scheme}://{0.netloc}/".format(urlsplit(url))

def cleanup(self):
self.begin_cleanup()
cleanup_flights_fp_client(
Expand Down
Loading

0 comments on commit a44b49e

Please sign in to comment.