import pytest from datetime import datetime from bt_df_data_retention_manager.jobs.engines.dataflow import DataflowJob, DataflowJobRuntimeParams @pytest.fixture def example_dataflow_params() -> DataflowJobRuntimeParams: params = DataflowJobRuntimeParams( bigtable_instance_id="stg-delphi-consumer-analytics-ssd", bigtable_table_id="charts", max_num_workers=10, delete_rows=False, project_id="delphi-stage", region="us-east4", row_key_regex= '(.+~20(1[0-9]|2[0-1])-(0[1-9]|1[0-2])-[0-3][0-9].*|.+~2022-0[1-9]-[0-3][0-9].*|.+~2022-10-[0-3][0-9].*)', staging_location="gs://stage-delphi-bt-archive/temp", template_location= "gs://delphi-dataflow-templates/templates/BigtableRemoveByRegex") # Adjust end date for testing return params @pytest.mark.skip( reason= "This is real job test on a real data, it needs to be performed only manually" ) def test_dataflow_job_creation(example_dataflow_params): job = DataflowJob(job_params=example_dataflow_params) r = job.get_template() print(r) r = job.create() assert job.is_running() == False job.wait_pending() assert job.is_running() == True job.check_timeout_hours(1) r = job.cancel() assert job.is_running() == False assert job.is_failed() == True