"""Unit test for updating accounting_run.run_status to 'Error'.""" from unittest.mock import MagicMock from unittest.mock import patch import pytest from lib.constants import ACCOUNTING_RUN_STATUSES from tasks.accounting_run_calculate_nr.update_run_status_error import status_error @patch('tasks.accounting_run_calculate_nr.update_run_status_error.helpers') @patch('tasks.accounting_run_calculate_nr.update_run_status_error.ows') def test_update_run_status_error( mock_ows, mock_helpers, mock_accounting_run_calculate_nr_dag_run ): """Test updating accounting_run_status to 'Error'.""" accounting_run_id = 123 mock_helpers.get_event_from_params.return_value = MagicMock( target_id=accounting_run_id ) with pytest.raises(ValueError): status_error(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.ERROR )