def test_add_tasks(self): dag = Dag("bqetl_test_dag", "daily", self.default_args) query_file = (TEST_DIR / "data" / "test_sql" / "moz-fx-data-test-project" / "test" / "incremental_query_v1" / "query.sql") scheduling = { "dag_name": "bqetl_test_dag", "default_args": { "owner": "*****@*****.**" }, "task_name": "custom_task_name", } metadata = Metadata("test", "test", ["*****@*****.**"], {}, scheduling) task1 = Task.of_query(query_file) task2 = Task.of_query(query_file, metadata) assert dag.tasks == [] dag.add_tasks([task1, task2]) assert len(dag.tasks) == 2
def test_add_tasks(self): dag = Dag("test_dag", "daily", {}) query_file = ( TEST_DIR / "data" / "test_sql" / "test" / "incremental_query_v1" / "query.sql" ) tasks = [Task.of_query(query_file), Task.of_query(query_file)] assert dag.tasks == [] dag.add_tasks(tasks) assert len(dag.tasks) == 2
def test_add_tasks_duplicate_names(self): dag = Dag("bqetl_test_dag", "daily", self.default_args) query_file = (TEST_DIR / "data" / "test_sql" / "test" / "incremental_query_v1" / "query.sql") scheduling = { "dag_name": "bqetl_test_dag", "default_args": { "owner": "*****@*****.**" }, "task_name": "duplicate_task_name", } metadata = Metadata("test", "test", ["*****@*****.**"], {}, scheduling) task = Task.of_query(query_file, metadata) with pytest.raises(ValueError): dag.add_tasks([task, task])