mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Another step in reducing the rigidity of FlightPlan and making it testable. There is one intentional behavior change here: escort flights no longer request escorts. That actually has a very minimal effect because these properties are only used for two things: determining if a package needs escorts or not, and determining when the TARCAP should show up and leave. Since escorts won't have been in the package when the first part happens anyway, that has no effect. The only change is that TARCAP won't show up earlier or stay later just because of a TOT offset for an escort flight.
86 lines
2.5 KiB
Python
86 lines
2.5 KiB
Python
from typing import cast, Any
|
|
|
|
import pytest
|
|
from dcs import Point
|
|
from dcs.terrain import Caucasus
|
|
|
|
from game.ato import Flight, FlightWaypoint
|
|
from game.ato.flightplans.custom import CustomFlightPlan, CustomLayout
|
|
from game.ato.flightplans.flightplan import FlightPlan
|
|
from game.ato.flightwaypointtype import FlightWaypointType
|
|
|
|
|
|
@pytest.fixture(name="unescorted_flight_plan")
|
|
def unescorted_flight_plan_fixture() -> FlightPlan[Any]:
|
|
point = Point(0, 0, Caucasus())
|
|
departure = FlightWaypoint("", FlightWaypointType.TAKEOFF, point)
|
|
|
|
waypoints = [
|
|
FlightWaypoint(f"{i}", FlightWaypointType.NAV, point) for i in range(10)
|
|
]
|
|
return CustomFlightPlan(cast(Flight, object()), CustomLayout(departure, waypoints))
|
|
|
|
|
|
@pytest.fixture(name="escorted_flight_plan")
|
|
def escorted_flight_plan_fixture() -> FlightPlan[Any]:
|
|
point = Point(0, 0, Caucasus())
|
|
departure = FlightWaypoint("", FlightWaypointType.TAKEOFF, point)
|
|
|
|
waypoints = [
|
|
FlightWaypoint(f"{i}", FlightWaypointType.NAV, point) for i in range(10)
|
|
]
|
|
waypoints[1].wants_escort = True
|
|
waypoints[2].wants_escort = True
|
|
waypoints[3].wants_escort = True
|
|
waypoints[5].wants_escort = True
|
|
waypoints[7].wants_escort = True
|
|
waypoints[8].wants_escort = True
|
|
return CustomFlightPlan(cast(Flight, object()), CustomLayout(departure, waypoints))
|
|
|
|
|
|
def test_escorted_flight_plan_escorted_waypoints(
|
|
escorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
assert [w.name for w in escorted_flight_plan.escorted_waypoints()] == [
|
|
"1",
|
|
"2",
|
|
"3",
|
|
"5",
|
|
"7",
|
|
"8",
|
|
]
|
|
|
|
|
|
def test_escorted_flight_plan_request_escort_at(
|
|
escorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
wp = escorted_flight_plan.request_escort_at()
|
|
assert wp is not None
|
|
assert wp.name == "1"
|
|
|
|
|
|
def test_escorted_flight_plan_dismiss_escort_at(
|
|
escorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
wp = escorted_flight_plan.dismiss_escort_at()
|
|
assert wp is not None
|
|
assert wp.name == "8"
|
|
|
|
|
|
def test_unescorted_flight_plan_escorted_waypoints(
|
|
unescorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
assert not list(unescorted_flight_plan.escorted_waypoints())
|
|
|
|
|
|
def test_unescorted_flight_plan_request_escort_at(
|
|
unescorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
assert unescorted_flight_plan.request_escort_at() is None
|
|
|
|
|
|
def test_unescorted_flight_plan_dismiss_escort_at(
|
|
unescorted_flight_plan: FlightPlan[Any],
|
|
) -> None:
|
|
assert unescorted_flight_plan.dismiss_escort_at() is None
|