Skip to content

Commit e2346c8

Browse files
authored
Breaking change in textual dependency (#331)
* update BLANK -> NULL in response to textual breaking change in v8 * add test
1 parent 440b179 commit e2346c8

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

src/virtualship/cli/_plan.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ def compose(self) -> ComposeResult:
736736
id=f"wp{self.index}_year",
737737
value=int(self.waypoint.time.year)
738738
if self.waypoint.time
739-
else Select.BLANK,
739+
else Select.NULL,
740740
prompt="YYYY",
741741
classes="year-select",
742742
)
@@ -746,7 +746,7 @@ def compose(self) -> ComposeResult:
746746
id=f"wp{self.index}_month",
747747
value=int(self.waypoint.time.month)
748748
if self.waypoint.time
749-
else Select.BLANK,
749+
else Select.NULL,
750750
prompt="MM",
751751
classes="month-select",
752752
)
@@ -756,7 +756,7 @@ def compose(self) -> ComposeResult:
756756
id=f"wp{self.index}_day",
757757
value=int(self.waypoint.time.day)
758758
if self.waypoint.time
759-
else Select.BLANK,
759+
else Select.NULL,
760760
prompt="DD",
761761
classes="day-select",
762762
)
@@ -766,7 +766,7 @@ def compose(self) -> ComposeResult:
766766
id=f"wp{self.index}_hour",
767767
value=int(self.waypoint.time.hour)
768768
if self.waypoint.time
769-
else Select.BLANK,
769+
else Select.NULL,
770770
prompt="hh",
771771
classes="hour-select",
772772
)
@@ -775,7 +775,7 @@ def compose(self) -> ComposeResult:
775775
minute_value = (
776776
int(self.waypoint.time.minute)
777777
if self.waypoint.time
778-
else Select.BLANK
778+
else Select.NULL
779779
)
780780

781781
# if the current minute is not a multiple of 5, add it to the options

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)