"""Unit testcases for snowflake query template.""" from unittest.mock import patch from generate_flowthrough_adjustments.snowflake_query_template import ( get_formatted_query, ) def test_get_formatted_query(): """Test get_formatted_query function.""" params = { 'payment_schedules': "'30_days_after_month_end','45_days_after_month_end','60_days_after_month_end'", 'reference_payment_entities': '1,2,3,4', 'current_statement_period_id': 329, } with patch.dict( 'generate_flowthrough_adjustments.snowflake_query_template.SNOWFLAKE_CONFIG', {'schema': 'Test'}, ): result = get_formatted_query('get_flowthrough_adjustment_records.sql', params) assert ( result.strip() == """ SELECT ac.account_name AS "Account Name", vw.account_id AS "Account ID", vw.contract_name AS "Contract Name", vw.contract_id AS "Contract ID", '' AS "UPC", vw.amount AS "Amount", vw.adjustment_payee_currency_code AS "Currency", '' AS "Activity Month", '' AS "Activity Year", '' AS "Statement Month", '' AS "Statement Year", vw.adjustment_type AS "Adjustment Type", vw.client_facing_comments AS "Client Facing Comments", '' AS "Distribution Type", '' AS "Internal Note", vw.apply_to_flowthrough_payment AS "Apply to Flowthrough Payment" FROM ROYALTY_ACCOUNTING_REPORTING.Test.VW_ABACUS_AUTOMATED_FLOWTHROUGH AS vw INNER JOIN ORCHARD_APP_REPORTING_V2.Test_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account ac ON ac.account_id=vw.account_id INNER JOIN ORCHARD_APP_REPORTING_V2.Test_ROYALTY_ACCOUNTING_ROYALTY_ACCOUNTING.account_payment_term apt ON apt.account_id=ac.account_id WHERE apt.payment_entity_id IN (1,2,3,4) AND apt.payment_schedule IN ('30_days_after_month_end','45_days_after_month_end','60_days_after_month_end') AND vw.statement_period_id = 329 AND vw.amount <> 0 AND vw.amount IS NOT NULL GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ORDER BY vw.account_id ASC; """.strip() )