"""Unit tests for YouTube Channel Names Workflow.""" from unittest import mock from unittest.mock import MagicMock from feed_ingestion.flows.youtube_channel_names.flow import Flow def test_decider(): """Test normal decider execution.""" schedule = MagicMock() schedule_result_object = MagicMock() schedule_result_object.result = {} schedule.return_value = schedule_result_object flow = Flow() flow.decider(schedule) schedule.assert_has_calls([ mock.call('bootstrap', mock.ANY), mock.call('get_missing_channels', mock.ANY, requires=mock.ANY), mock.call( 'create_temp_staging_raw_table', mock.ANY, requires=mock.ANY), mock.call('load_temp_staging_raw_table', mock.ANY, requires=mock.ANY), mock.call('update_dim_table', mock.ANY, requires=mock.ANY), mock.call('drop_temp_staging_table', mock.ANY, requires=mock.ANY), mock.call('set_status_to_ingested', mock.ANY, requires=mock.ANY) ]) def test_decider_should_stop_when_data_already_ingested(): """Decider quits if data is already ingested.""" bootstrap = MagicMock() bootstrap.result = {'bootstrap.stop': True} schedule = MagicMock(return_value=bootstrap) flow = Flow() result = flow.decider(schedule) assert result is None schedule.assert_has_calls([mock.call('bootstrap', mock.ANY)])