"""Tests for the Flow.""" from unittest.mock import ANY from unittest.mock import Mock from unittest.mock import call from analytics_aggregation.flows.spotify_demographics import flow def test_for_decider(): """Test for Flow decider.""" activity = Mock() activity.result = {} scheduler = Mock(return_value=activity) f = flow.Flow() f.create = Mock(return_value='activity') f.decider(scheduler) scheduler.assert_has_calls([ call('bootstrap', 'activity'), call('populate_fact_demographics', 'activity', requires=[ANY]), call('set_status_to_ingested', 'activity', requires=[ANY])]) def test_for_decider_stop_after_bootstrap(): """Test for Flow decider.""" activity = Mock() activity.result = {'bootstrap.stop': True} scheduler = Mock(return_value=activity) f = flow.Flow() f.create = Mock(return_value='activity') f.decider(scheduler) assert scheduler.call_count == 1 scheduler.assert_has_calls([call('bootstrap', 'activity')])