diff --git a/src/virtualship/utils.py b/src/virtualship/utils.py index cef83501..204e9e8f 100644 --- a/src/virtualship/utils.py +++ b/src/virtualship/utils.py @@ -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 = ( diff --git a/tests/test_utils.py b/tests/test_utils.py index 00165f27..8f9ec016 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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