import pytest from pytest_mock import MockerFixture from src.index import handler def test_handler_executes_transfer_and_preserves_event(mocker: MockerFixture) -> None: mock_execute = mocker.patch("src.index.execute_content_transfer") mock_execute.return_value = { "project_updated": 1, "releases_updated": 2, "video_rows_updated": 0, } result = handler( { "job_id": 42, "source_vendor_id": 10, "destination_vendor_id": 99, }, object(), ) assert result == { "job_id": 42, "source_vendor_id": 10, "destination_vendor_id": 99, "execute_content_transfer_result": { "project_updated": 1, "releases_updated": 2, "video_rows_updated": 0, }, } mock_execute.assert_called_once_with(42) def test_handler_raises_on_missing_job_id() -> None: with pytest.raises(KeyError): handler({}, object()) def test_handler_raises_on_invalid_job_id() -> None: with pytest.raises(ValueError, match="must be an integer"): handler({"job_id": "not-an-int"}, object())