def test_get_contextual_events_empty_search_results():
    """
    Tests behavior when search_events returns empty lists for before and after.
    """
    mock_event_stream = MagicMock(spec=EventStream)
    target_event_id = 10
    context_size = 4

    # search_events will return empty lists
    simulated_search_before = []
    simulated_search_after = []

    mock_event_stream.search_events.side_effect = [
        simulated_search_before,
        simulated_search_after,
    ]

    result_str = _get_contextual_events(mock_event_stream, target_event_id)

    expected_output_str = ''  # Empty string as no events are found

    assert result_str == expected_output_str

    calls = mock_event_stream.search_events.call_args_list
    assert len(calls) == 2
    kwargs_before = calls[0][1]
    assert kwargs_before['start_id'] == target_event_id
    assert kwargs_before['limit'] == context_size
    kwargs_after = calls[1][1]
    assert kwargs_after['start_id'] == target_event_id + 1
    assert kwargs_after['limit'] == context_size + 1

    Tests behavior when search_events returns empty lists for before and after.
    
tests/unit/test_contextual_events.py