Skip to content

Commit 51eb0ba

Browse files
committed
add test
1 parent c4904df commit 51eb0ba

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/cli/test_plan.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,52 @@ async def test_UI_changes():
150150

151151
# cleanup
152152
shutil.rmtree(tmpdir)
153+
154+
155+
@pytest.mark.asyncio
156+
async def test_UI_opens_with_null_time_and_instrument():
157+
"""Test that the UI opens correctly when waypoints have time: null and instrument: null."""
158+
tmpdir = Path(tempfile.mkdtemp())
159+
160+
instruments_config = InstrumentsConfig.model_validate(
161+
yaml.safe_load(get_example_expedition()).get("instruments_config")
162+
)
163+
ship_config = yaml.safe_load(get_example_expedition()).get("ship_config")
164+
waypoints = [
165+
Waypoint(
166+
location=Location(0, 0),
167+
time=datetime(2022, 1, 1, 0, 0, 0),
168+
instrument=["CTD"],
169+
),
170+
Waypoint(
171+
location=Location(0.01, 0.01),
172+
time=None,
173+
instrument=None,
174+
),
175+
Waypoint(
176+
location=Location(0.02, 0.02),
177+
time=None,
178+
instrument=None,
179+
),
180+
]
181+
expedition = Expedition(
182+
schedule=Schedule(waypoints=waypoints),
183+
instruments_config=instruments_config,
184+
ship_config=ship_config,
185+
)
186+
187+
expedition.to_yaml(tmpdir / EXPEDITION)
188+
189+
app = PlanApp(path=tmpdir)
190+
191+
async with app.run_test(size=(120, 100)) as pilot:
192+
await pilot.pause(0.5)
193+
194+
plan_screen = pilot.app.screen
195+
expedition_editor = plan_screen.query_one(ExpeditionEditor)
196+
197+
# verify the app opened without errors by checking the editor loaded
198+
assert expedition_editor is not None
199+
200+
# cleanup
201+
shutil.rmtree(tmpdir)

0 commit comments

Comments
 (0)