"""Unit tests for Ticketek Workflow.""" from unittest import mock from unittest.mock import MagicMock from feed_ingestion.flows.ticketek.flow import Flow def test_decider(): """Test normal decider execution.""" schedule = MagicMock() # Create mock results bootstrap_mock = MagicMock() bootstrap_mock.result.get.side_effect = lambda \ key: False if key == 'bootstrap.stop' \ else True if key == 'bootstrap.is_set_overall_ingested' else None check_files_on_s3_mock = MagicMock() check_files_on_s3_mock.result.get.side_effect = lambda \ key: False if key == 'check_files_on_s3.stop' else None # Mock the schedule calls to return these mocks schedule.side_effect = [bootstrap_mock, check_files_on_s3_mock, MagicMock(), MagicMock()] flow = Flow() flow.decider(schedule) schedule.assert_has_calls([ mock.call('bootstrap', mock.ANY), # mock.call().result.get('bootstrap.stop'), mock.call('check_files_on_s3', mock.ANY, requires=mock.ANY), # mock.call().result.get('check_files_on_s3.stop'), mock.call( 'load_staging_raw_table', mock.ANY, requires=mock.ANY ), # mock.call().result.get('bootstrap.is_set_overall_ingested'), mock.call('set_overall_status_ingested', mock.ANY, requires=mock.ANY), ])