"""Grps Ingestor Flow Control tests.""" from unittest.mock import ANY, call, patch from src.index import handler @patch('src.index.sfn.get_full_execution_count_by_arn') @patch('src.index.sfn.start_execution_by_arn') @patch('src.index.update_grps_ingestion') @patch('src.index.get_upc_to_process') def test_handler(mock_get_upc_to_process, mock_update_grps_ingestion, mock_start_execution_by_arn, mock_get_full_execution_count_by_arn): """Test handler function.""" mock_get_upc_to_process.return_value = [ ('upc_1', 'run_id_1', 'prod_no_1'), ('upc_2', 'run_id_2', 'prod_no_2'), ('upc_3', 'run_id_3', 'prod_no_3'), ] mock_get_full_execution_count_by_arn.return_value = 0 mock_start_execution_by_arn.return_value = (None, 'test_name') handler({'MAX_STATE_MACHINES': 5}, None) mock_start_execution_by_arn.assert_has_calls([ call(ANY, 'upc_1', 'run_id_1', 'prod_no_1'), call(ANY, 'upc_2', 'run_id_2', 'prod_no_2'), call(ANY, 'upc_3', 'run_id_3', 'prod_no_3'), ]) mock_update_grps_ingestion.assert_has_calls( [call('run_id_1', 'INGEST_STARTED', 'test_name'), call('run_id_2', 'INGEST_STARTED', 'test_name'), call('run_id_3', 'INGEST_STARTED', 'test_name') ]) @patch('src.index.sfn.get_full_execution_count_by_arn') @patch('src.index.sfn.start_execution_by_arn') @patch('src.index.get_upc_to_process') def test_handler_with_max_state_machines(mock_get_upc_to_process, mock_start_execution_by_arn, mock_get_full_execution_count_by_arn): """Test MAX_STATE_MACHINES parameter.""" mock_get_full_execution_count_by_arn.return_value = 10 handler({'MAX_STATE_MACHINES': 5}, None) mock_start_execution_by_arn.assert_not_called()