"""Unit tests for accounting_run_calculate_nr task helpers.""" from unittest.mock import patch from lib import constants from tasks.accounting_run_calculate_nr import helpers @patch('tasks.accounting_run_calculate_nr.helpers.event') def test_get_event_from_params(mock_event, mock_accounting_run_calculate_nr_dag_run): """Test getting the accounting_run_calculate_nr abacus_event from DAG params.""" mock_abacus_event = 'abacus_event' mock_event.get_abacus_event.return_value = mock_abacus_event mock_event.validate_event_for_handler.return_value = True result = helpers.get_event_from_params(mock_accounting_run_calculate_nr_dag_run) assert result == mock_abacus_event mock_event.get_abacus_event.assert_called_once_with( mock_accounting_run_calculate_nr_dag_run ) mock_event.validate_event_for_handler.assert_called_once_with( mock_abacus_event, target_type=constants.DAG_CALC_TARGET_TYPE, event_name=constants.DAG_NR_CALC_EVENT_NAME )