"""Test report import models.""" from unittest.mock import call, MagicMock from constants import general from models import reports import common_config def test_import_overlap_report(): """Test import overlap report is executed with correct parameters.""" today = '2018-09-20' snowflake_executor = MagicMock() csv_key = 'soundexchange/overlap/converted/2018_09_20/overlap.csv' xls_key = 'soundexchange/overlap/input/2018_09_20/overlap.xlsx' reports.import_overlap_report(snowflake_executor, today, csv_key, xls_key) expected_query_params = { 'db': common_config.SNOWFLAKE_CONFIG['db'], 'schema': common_config.SNOWFLAKE_CONFIG['schema'], 'warehouse': common_config.SNOWFLAKE_CONFIG['warehouse'], 'table': 'soundexchange_overlap', 's3_path': f's3://{common_config.S3_BUCKET}/{csv_key}', 'aws_access_key_id': common_config.AWS_ACCESS_KEY_ID, 'aws_secret_access_key': common_config.AWS_SECRET_ACCESS_KEY, 'import_date': today, 'report_file': xls_key } snowflake_executor.execute_query.assert_has_calls([ call( reports.sql_loader, general.CREATE_STAGE_QUERY, expected_query_params), call( reports.sql_loader, general.IMPORT_QUERY, expected_query_params), call( reports.sql_loader, general.SET_DATE_AND_REPORT_NAME_QUERY, expected_query_params) ])