"""Test snowflake_copy_mech_deductions.""" from unittest.mock import patch from lib import config from tasks.accounting_run_commit.snowflake_copy_mech_deductions import\ copy_mech_deductions @patch('tasks.accounting_run_commit.snowflake_copy_mech_deductions.RoyaltySnowflakeHook') # noqa: E501 @patch('tasks.accounting_run_commit.snowflake_copy_mech_deductions.copy_mech_deductions_template') # noqa: E501 @patch('tasks.accounting_run_commit.snowflake_copy_mech_deductions.get_event_from_params') # noqa: E501 def test_copy_mech_deductions_success( mock_get_event, mock_template, mock_hook, mock_commit_event, mock_commit_dag_run, # mock_accounting_run, ): """Test using snowflake hook to copy distribution contract mech deductions from staging to 'final' table.""" # noqa: E501 accounting_run_id = mock_commit_event.get('target_id') config.OWS_ENV = 'dev' mock_get_event.return_value.target_id = accounting_run_id mock_template.return_value.render.return_value = 'COPY STATEMENT' mock_hook.return_value.run.return_value = True copy_mech_deductions(mock_commit_dag_run) mock_get_event.assert_called_once_with(mock_commit_dag_run) mock_hook.assert_called_once_with(snowflake_conn_id=config.SNOWFLAKE_CONN_NAME) mock_template.assert_called_once() mock_template.return_value.render.assert_called_once_with( accounting_run_id=accounting_run_id, environment=config.OWS_ENV, ) mock_hook.return_value.run.assert_called_once()