import pytest from tadas.snowflake import facts_source @pytest.mark.parametrize( 'group_by_country', [True, False], ) def test_prepare_sql_select_group_by_country(snapshot, group_by_country): spotify_store_id = 286 spotify_streams_feed_id = 1 selected_columns = { 'total_streams': dict(column='STREAMS'), 'total_skips': dict(column='SKIPS'), 'spotify_streams_active': dict( condition=f'storeid={spotify_store_id} and feedid={spotify_streams_feed_id}', column='STREAMS_ACTIVE', ), 'spotify_streams': dict( condition=f'storeid={spotify_store_id} and feedid={spotify_streams_feed_id}', column='STREAMS', ), } table_name = 'test_table' PREFIX_YEST = 'yest_' PREFIX_SEVEN = 'seven_' PERIODS = { 'today': { 'date_range': '%(current_date)s::date', 'column_prefix': '', }, 'yesterday': { 'date_range': '%(current_date)s::date - 1', 'column_prefix': PREFIX_YEST, }, 'week_ago': { 'date_range': '%(current_date)s::date - 7', 'column_prefix': PREFIX_SEVEN, }, } sp_q_t = facts_source.prepare_sql_select_from_dbt_model( source_table=table_name, tracks_table='tracks_table', columns_definition=selected_columns, group_by_country=group_by_country, periods=PERIODS ) assert sp_q_t == snapshot