"""Unit tests for flow class.""" from unittest import TestCase from unittest.mock import Mock from unittest.mock import patch from flows.cable_ingestion.flow import Flow class FlowTest(TestCase): """FlowTest.""" def setUp(self): """Patching.""" self.patched_tasks = patch('flows.cable_ingestion.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_inge', '1.0') schedule = Mock() flow.decider(schedule) tasks = { 'extract_from_source', 'create_temp_raw_table', 'insert_to_temp_raw_table', 'insert_select_to_raw_table', 'update_etl_status', 'update_dashboard_status'} for call in schedule.call_args_list: tasks.remove(call[0][0]) assert not tasks def test_decider_skip(self): """Test decider function with invalid files.""" flow = Flow('test', 'testcable_inge', '1.0') first_task = Mock() first_task.result.get.return_value = False schedule = Mock() schedule.return_value = first_task flow.decider(schedule) tasks = {'extract_from_source'} for call in schedule.call_args_list: tasks.remove(call[0][0]) assert not tasks