"""Unit tests for flow class.""" from unittest import TestCase from unittest.mock import Mock from unittest.mock import patch from flows.cable_calculation.flow import Flow class FlowTest(TestCase): """FlowTest.""" def setUp(self): """Patching.""" self.patched_tasks = patch('flows.cable_calculation.flow.tasks') self.tasks = self.patched_tasks.start() self.addCleanup(self.patched_tasks.stop) def test_decider(self): """Test decider function.""" flow = Flow('test', 'testcable_calc', '1.0') schedule = Mock() schedule.return_value = Mock(result={'stop': False}) flow.decider(schedule) tasks = { 'create_temp_table', 'unload_calculate_load_temp_table', 'move_temp_table_to_cable_revenue', 'send_notification', 'finalize_etl_status'} for call in schedule.call_args_list: tasks.remove(call[0][0]) assert not tasks def test_decider_stop(self): """Test decider function with unload task returning stop flag.""" flow = Flow('test', 'testcable_calc', '1.0') schedule = Mock() schedule.return_value = Mock(result={'stop': True}) flow.decider(schedule) tasks = {'create_temp_table', 'unload_calculate_load_temp_table'} for call in schedule.call_args_list: tasks.remove(call[0][0]) assert not tasks