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
6 changes: 3 additions & 3 deletions src/virtualship/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ def _calc_wp_stationkeeping_time(
"""For a given waypoint (and the instruments present at this waypoint), calculate how much time is required to carry out all instrument deployments."""
from virtualship.instruments.types import InstrumentType # avoid circular imports

assert isinstance(wp_instrument_types, list), (
"waypoint instruments must be provided as a list, even if empty."
)
# to empty list if wp instruments set to 'null'
if not wp_instrument_types:
wp_instrument_types = []

# TODO: this can be removed if/when CTD and CTD_BGC are merged to a single instrument
both_ctd_and_bgc = (
Expand Down
13 changes: 13 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,16 @@ class DrifterConfig:
assert stationkeeping_time_xbt == datetime.timedelta(0), (
"XBT should have zero stationkeeping time"
)


def test_calc_wp_stationkeeping_time_no_instruments(expedition):
"""Test calc_wp_stationkeeping_time handles no instruments, either marked as 'null' or empty list."""
stationkeeping_emptylist = _calc_wp_stationkeeping_time(
[], expedition.instruments_config
)
stationkeeping_null = _calc_wp_stationkeeping_time(
None, expedition.instruments_config
) # "null" in YAML translates to None in Python

assert stationkeeping_null == stationkeeping_emptylist # are equivalent
assert stationkeeping_null == datetime.timedelta(0) # at least one is 0 time