"""Tests for the Flow class of the sql2sf workflow.""" import pytest from snowflake_etl.flows.sql2sf import flow @pytest.fixture def start_period(): """Fixture returning the start_period.""" return '2016-08-27' @pytest.fixture def end_period(): """Fixture returning the end_period.""" return '2016-08-28' @pytest.fixture(params=['date_range', 'sync_incremental', 'snapshot']) def query_type(request): """Fixture returning query types.""" return request.param @pytest.fixture(params=['snapshot', 'incremental']) def load_strategy(request): """Fixture returning load strategy types.""" return request.param @pytest.fixture(params=['production', 'pricing']) def source_schema(request): """Fixture returning possible source schemas.""" return request.param @pytest.fixture(params=['dim_zip', 'fact_analytics']) def source_table(request): """Fixture returning possible tables to work with.""" return request.param @pytest.fixture(params=['redshift', 'mysql']) def db_type(request): """Fixture returning possible db_type.""" return request.param def test_workflow_id_method( db_type, source_table, source_schema, query_type, start_period, end_period, load_strategy): """Test creation of the workflow id.""" sql2sf_flow = flow.Flow() context = { 'query_type': query_type, 'source_schema': source_schema, 'load_strategy': load_strategy, 'start_period': start_period, 'end_period': end_period, 'db_type': db_type, 'source_table': source_table, 'sfdb_params': { 'db': 'testdb', 'schema': 'testschema' } } workflow_id = sql2sf_flow.workflow_id(context) assert db_type in workflow_id assert source_table in workflow_id assert source_schema in workflow_id assert query_type in workflow_id if query_type == 'date_range' or query_type == 'sync_incremental': assert start_period in workflow_id assert end_period in workflow_id else: assert start_period not in workflow_id assert end_period not in workflow_id