Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/virtualship/cli/_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def compose(self) -> ComposeResult:
id=f"wp{self.index}_year",
value=int(self.waypoint.time.year)
if self.waypoint.time
else Select.BLANK,
else Select.NULL,
prompt="YYYY",
classes="year-select",
)
Expand All @@ -746,7 +746,7 @@ def compose(self) -> ComposeResult:
id=f"wp{self.index}_month",
value=int(self.waypoint.time.month)
if self.waypoint.time
else Select.BLANK,
else Select.NULL,
prompt="MM",
classes="month-select",
)
Expand All @@ -756,7 +756,7 @@ def compose(self) -> ComposeResult:
id=f"wp{self.index}_day",
value=int(self.waypoint.time.day)
if self.waypoint.time
else Select.BLANK,
else Select.NULL,
prompt="DD",
classes="day-select",
)
Expand All @@ -766,7 +766,7 @@ def compose(self) -> ComposeResult:
id=f"wp{self.index}_hour",
value=int(self.waypoint.time.hour)
if self.waypoint.time
else Select.BLANK,
else Select.NULL,
prompt="hh",
classes="hour-select",
)
Expand All @@ -775,7 +775,7 @@ def compose(self) -> ComposeResult:
minute_value = (
int(self.waypoint.time.minute)
if self.waypoint.time
else Select.BLANK
else Select.NULL
)

# if the current minute is not a multiple of 5, add it to the options
Expand Down
49 changes: 49 additions & 0 deletions tests/cli/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,52 @@ async def test_UI_changes():

# cleanup
shutil.rmtree(tmpdir)


@pytest.mark.asyncio
async def test_UI_opens_with_null_time_and_instrument():
"""Test that the UI opens correctly when waypoints have time: null and instrument: null."""
tmpdir = Path(tempfile.mkdtemp())

instruments_config = InstrumentsConfig.model_validate(
yaml.safe_load(get_example_expedition()).get("instruments_config")
)
ship_config = yaml.safe_load(get_example_expedition()).get("ship_config")
waypoints = [
Waypoint(
location=Location(0, 0),
time=datetime(2022, 1, 1, 0, 0, 0),
instrument=["CTD"],
),
Waypoint(
location=Location(0.01, 0.01),
time=None,
instrument=None,
),
Waypoint(
location=Location(0.02, 0.02),
time=None,
instrument=None,
),
]
expedition = Expedition(
schedule=Schedule(waypoints=waypoints),
instruments_config=instruments_config,
ship_config=ship_config,
)

expedition.to_yaml(tmpdir / EXPEDITION)

app = PlanApp(path=tmpdir)

async with app.run_test(size=(120, 100)) as pilot:
await pilot.pause(0.5)

plan_screen = pilot.app.screen
expedition_editor = plan_screen.query_one(ExpeditionEditor)

# verify the app opened without errors by checking the editor loaded
assert expedition_editor is not None

# cleanup
shutil.rmtree(tmpdir)
Loading