from region import Region


def test_scalar_tick_does_not_directly_forward_bound_layers():
    region = Region("graph-only")
    target_layer_index = region.add_layer(1, 0, 0)
    region.bind_input("signal", [target_layer_index])

    target_layer = region.get_layers()[target_layer_index]
    original_forward = target_layer.forward
    forward_calls = {"count": 0}

    def fail_on_direct_forward(value):
        forward_calls["count"] += 1
        raise AssertionError(f"unexpected direct forward with value {value}")

    target_layer.forward = fail_on_direct_forward
    try:
        region.tick("signal", 0.5)
    finally:
        target_layer.forward = original_forward

    assert forward_calls["count"] == 0
