|
7 | 7 | from virtualship import Location |
8 | 8 | from virtualship.expedition import Waypoint |
9 | 9 | from virtualship.expedition.do_expedition import _load_input_data |
| 10 | +from virtualship.expedition.schedule import Schedule, ScheduleError |
10 | 11 | from virtualship.utils import _get_ship_config |
11 | | -from virtualship.expedition.schedule import ScheduleError, Schedule |
12 | | - |
13 | 12 |
|
14 | 13 | projection = pyproj.Geod(ellps="WGS84") |
15 | 14 |
|
@@ -56,81 +55,107 @@ def test_get_instruments() -> None: |
56 | 55 | waypoints=[ |
57 | 56 | Waypoint(location=Location(0, 0), instrument=["CTD"]), |
58 | 57 | Waypoint(location=Location(1, 0), instrument=["XBT", "ARGO_FLOAT"]), |
59 | | - Waypoint(location=Location(1, 0), instrument=["CTD"]) |
| 58 | + Waypoint(location=Location(1, 0), instrument=["CTD"]), |
60 | 59 | ] |
61 | 60 | ) |
62 | 61 |
|
63 | | - assert set(instrument.name for instrument in schedule.get_instruments()) == {"CTD", "XBT", "ARGO_FLOAT"} |
| 62 | + assert set(instrument.name for instrument in schedule.get_instruments()) == { |
| 63 | + "CTD", |
| 64 | + "XBT", |
| 65 | + "ARGO_FLOAT", |
| 66 | + } |
64 | 67 |
|
65 | 68 |
|
66 | 69 | @pytest.mark.parametrize( |
67 | 70 | "schedule,check_space_time_region,error,match", |
68 | 71 | [ |
69 | 72 | pytest.param( |
70 | | - Schedule( |
71 | | - waypoints=[] |
72 | | - ), |
| 73 | + Schedule(waypoints=[]), |
73 | 74 | False, |
74 | 75 | ScheduleError, |
75 | 76 | "At least one waypoint must be provided.", |
76 | | - id="NoWaypoints" |
| 77 | + id="NoWaypoints", |
77 | 78 | ), |
78 | 79 | pytest.param( |
79 | 80 | Schedule( |
80 | 81 | waypoints=[ |
81 | 82 | Waypoint(location=Location(0, 0)), |
82 | | - Waypoint(location=Location(1, 0), time=datetime(2022, 1, 1, 1, 0, 0)), |
| 83 | + Waypoint( |
| 84 | + location=Location(1, 0), time=datetime(2022, 1, 1, 1, 0, 0) |
| 85 | + ), |
83 | 86 | ] |
84 | 87 | ), |
85 | 88 | False, |
86 | 89 | ScheduleError, |
87 | 90 | "First waypoint must have a specified time.", |
88 | | - id="FirstWaypointHasTime" |
| 91 | + id="FirstWaypointHasTime", |
89 | 92 | ), |
90 | 93 | pytest.param( |
91 | 94 | Schedule( |
92 | 95 | waypoints=[ |
93 | | - Waypoint(location=Location(0, 0), time=datetime(2022, 1, 2, 1, 0, 0)), |
| 96 | + Waypoint( |
| 97 | + location=Location(0, 0), time=datetime(2022, 1, 2, 1, 0, 0) |
| 98 | + ), |
94 | 99 | Waypoint(location=Location(0, 0)), |
95 | | - Waypoint(location=Location(1, 0), time=datetime(2022, 1, 1, 1, 0, 0)), |
| 100 | + Waypoint( |
| 101 | + location=Location(1, 0), time=datetime(2022, 1, 1, 1, 0, 0) |
| 102 | + ), |
96 | 103 | ] |
97 | 104 | ), |
98 | 105 | False, |
99 | 106 | ScheduleError, |
100 | 107 | "Each waypoint should be timed after all previous waypoints", |
101 | | - id="SequentialWaypoints" |
| 108 | + id="SequentialWaypoints", |
102 | 109 | ), |
103 | 110 | pytest.param( |
104 | 111 | Schedule( |
105 | 112 | waypoints=[ |
106 | | - Waypoint(location=Location(0, 0), time=datetime(2022, 1, 1, 1, 0, 0)), |
107 | | - Waypoint(location=Location(1, 0), time=datetime(2022, 1, 1, 1, 1, 0)), |
| 113 | + Waypoint( |
| 114 | + location=Location(0, 0), time=datetime(2022, 1, 1, 1, 0, 0) |
| 115 | + ), |
| 116 | + Waypoint( |
| 117 | + location=Location(1, 0), time=datetime(2022, 1, 1, 1, 1, 0) |
| 118 | + ), |
108 | 119 | ] |
109 | 120 | ), |
110 | 121 | False, |
111 | 122 | ScheduleError, |
112 | 123 | "Waypoint planning is not valid: would arrive too late at waypoint number 2...", |
113 | | - id="NotEnoughTime" |
| 124 | + id="NotEnoughTime", |
114 | 125 | ), |
115 | 126 | pytest.param( |
116 | 127 | Schedule( |
117 | 128 | waypoints=[ |
118 | | - Waypoint(location=Location(0, 0), time=datetime(2022, 1, 1, 1, 0, 0)), |
119 | | - Waypoint(location=Location(1, 0), time=datetime(2022, 1, 2, 1, 1, 0)), |
| 129 | + Waypoint( |
| 130 | + location=Location(0, 0), time=datetime(2022, 1, 1, 1, 0, 0) |
| 131 | + ), |
| 132 | + Waypoint( |
| 133 | + location=Location(1, 0), time=datetime(2022, 1, 2, 1, 1, 0) |
| 134 | + ), |
120 | 135 | ] |
121 | 136 | ), |
122 | 137 | True, |
123 | 138 | ScheduleError, |
124 | 139 | "space_time_region not found in schedule, please define it to fetch the data.", |
125 | | - id="NoSpaceTimeRegion" |
| 140 | + id="NoSpaceTimeRegion", |
126 | 141 | ), |
127 | | - ] |
| 142 | + ], |
128 | 143 | ) |
129 | | -def test_verify_schedule_errors(schedule: Schedule, check_space_time_region: bool, error, match) -> None: |
130 | | - |
| 144 | +def test_verify_schedule_errors( |
| 145 | + schedule: Schedule, check_space_time_region: bool, error, match |
| 146 | +) -> None: |
131 | 147 | ship_config = _get_ship_config(expedition_dir) |
132 | 148 |
|
133 | | - input_data = _load_input_data(expedition_dir, schedule, ship_config, input_data=Path("expedition_dir/input_data")) |
| 149 | + input_data = _load_input_data( |
| 150 | + expedition_dir, |
| 151 | + schedule, |
| 152 | + ship_config, |
| 153 | + input_data=Path("expedition_dir/input_data"), |
| 154 | + ) |
134 | 155 |
|
135 | 156 | with pytest.raises(error, match=match): |
136 | | - schedule.verify(ship_config.ship_speed_knots, input_data, check_space_time_region=check_space_time_region) |
| 157 | + schedule.verify( |
| 158 | + ship_config.ship_speed_knots, |
| 159 | + input_data, |
| 160 | + check_space_time_region=check_space_time_region, |
| 161 | + ) |
0 commit comments