"""Sequence playback targets only explicitly checked lane groups."""

from util.sequence_playback import (
    _group_ids_for_lane_step,
    _partition_devices_for_lane,
    _resolve_step_device_names,
    _split_device_names_for_lane,
)


def test_empty_lane_groups_do_not_default_to_zone():
    zone = {"group_ids": ["g1", "g2"]}
    seq = {"lanes": [[{"preset_id": "1", "beats": 1}]], "lanes_group_ids": [[]]}
    gids = _group_ids_for_lane_step(seq, seq["lanes"][0][0], 0, 1, zone_doc=zone)
    assert gids == []


def test_resolve_step_with_no_groups_returns_empty():
    zone = {"group_ids": ["g1"], "names": ["dev-a"]}
    names = _resolve_step_device_names(zone, [], None, None)
    assert names == []


def test_whole_zone_not_partitioned_across_lanes():
    names = ["dev-a", "dev-b", "dev-c"]
    assert _split_device_names_for_lane(names, 0, 2, partition_shared_zone=False) == names
    assert _split_device_names_for_lane(names, 1, 2, partition_shared_zone=False) == names
    assert not _partition_devices_for_lane(2, lane_has_own_groups=False, step_group_ids=[])
