"""Unit tests for snowflake_snapshot_contracts_nr task.""" from unittest.mock import patch from lib import config from tasks.accounting_run_calculate_nr.snowflake_snapshot_contracts \ import insert_snapshot_contracts_nr_task import_path = 'tasks.accounting_run_calculate_nr.snowflake_snapshot_contracts' @patch(f'{import_path}.RoyaltySnowflakeHook') @patch(f'{import_path}.helpers') @patch(f'{import_path}.insert_snapshot_contract_nr_template') def test_snowflake_snapshot_contracts_nr_task_old( mock_template, mock_helpers, mock_hook, mock_accounting_run_calculate_nr_dag_run ): """Test task that snapshots royalty_accounting contract data into snowflake.""" accounting_run_id = 123 mock_helpers.get_event_from_params.return_value.target_id = accounting_run_id mock_template.return_value.render.return_value = \ 'INSERT INTO CONTRACT_SNAPSHOT_NR FROM royalty_accounting REPLICA' mock_hook.return_value.run.return_value = True insert_snapshot_contracts_nr_task(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_hook.assert_called_once_with(snowflake_conn_id=config.SNOWFLAKE_CONN_NAME) mock_template.return_value.render.assert_called_once_with( accounting_run_id=accounting_run_id, env='qa', schema=config.OWS_ENV, ) mock_hook.return_value.run.assert_called_once()