"""Unit tests for Spotify Charts Workflow.""" from unittest import mock from unittest.mock import MagicMock from feed_ingestion.flows.spotify_charts.flow import Flow def test_decider_chart_unavailable(): """Test decider execution when chart is unavailable.""" check_status = MagicMock() check_status.result = { 'grab_drop_files.stop': True} schedule = MagicMock(return_value=check_status) flow = Flow() flow.decider(schedule) schedule.assert_has_calls([ mock.call('bootstrap', mock.ANY), mock.call('grab_drop_files', mock.ANY, requires=mock.ANY)]) def test_decider_chart_available(): """Test decider execution when chart is available.""" check_status = MagicMock() check_status.result = { 'grab_drop_files.stop': False} schedule = MagicMock(return_value=check_status) flow = Flow() flow.decider(schedule) schedule.assert_has_calls([ mock.call('bootstrap', mock.ANY), mock.call('grab_drop_files', 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('clean_staging_raw_table', mock.ANY, requires=mock.ANY), mock.call('load_staging_raw_table', mock.ANY, requires=mock.ANY), mock.call('load_staging_charts_data', mock.ANY, requires=mock.ANY), mock.call('build_jenkins_charts', mock.ANY, requires=mock.ANY), mock.call('set_status_to_ingested', mock.ANY, requires=mock.ANY)])