"""Unit test for updating accounting_run.run_status to 'Running'.""" from unittest.mock import MagicMock from unittest.mock import patch from lib.constants import ACCOUNTING_RUN_STATUSES from tasks.accounting_run_calculate_nr.update_run_status_started import status_started @patch('tasks.accounting_run_calculate_nr.update_run_status_started.helpers') @patch('tasks.accounting_run_calculate_nr.update_run_status_started.ows') def test_update_run_status_started( mock_ows, mock_helpers, mock_accounting_run_calculate_nr_dag_run ): """Test updating accounting_run_status to 'Running'.""" accounting_run_id = 123 mock_helpers.get_event_from_params.return_value = MagicMock( target_id=accounting_run_id ) status_started(mock_accounting_run_calculate_nr_dag_run) mock_helpers.get_event_from_params.assert_called_once_with( mock_accounting_run_calculate_nr_dag_run ) mock_ows.update_accounting_run.assert_called_once_with( accounting_run_id, accounting_run_status=ACCOUNTING_RUN_STATUSES.RUNNING )