"""Unit tests for accounting_period_close task helpers.""" from unittest.mock import patch from lib import constants from tasks.accounting_period_close import helpers @patch('tasks.accounting_period_close.helpers.event') def test_get_event_from_params( mock_accounting_period_close_event, mock_accounting_period_close_dag_run ): """Test getting the accounting_period_close abacus_event from DAG params.""" mock_abacus_event = 'abacus_event' mock_accounting_period_close_event.get_abacus_event.return_value = mock_abacus_event mock_accounting_period_close_event.validate_event_for_handler.return_value = True result = helpers.get_event_from_params(mock_accounting_period_close_dag_run) assert result == mock_abacus_event mock_accounting_period_close_event.get_abacus_event.assert_called_once_with( mock_accounting_period_close_dag_run ) mock_accounting_period_close_event.validate_event_for_handler\ .assert_called_once_with( mock_abacus_event, target_type=constants.DAG_ACCOUNTING_PERIOD_CLOSE_TARGET_TYPE, event_name=constants.DAG_ACCOUNTING_PERIOD_CLOSE_EVENT_NAME )