From 55181c1725f45d39a9800ed07826955616043be7 Mon Sep 17 00:00:00 2001 From: pankajastro Date: Fri, 15 Nov 2024 16:53:55 +0530 Subject: [PATCH] Add some tests --- tests/operators/test_local.py | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/operators/test_local.py b/tests/operators/test_local.py index 2de6ca1e3..7cdf432dc 100644 --- a/tests/operators/test_local.py +++ b/tests/operators/test_local.py @@ -29,6 +29,7 @@ from cosmos.hooks.subprocess import FullOutputSubprocessResult from cosmos.operators.local import ( DbtBuildLocalOperator, + DbtCloneLocalOperator, DbtCompileLocalOperator, DbtDocsAzureStorageLocalOperator, DbtDocsGCSLocalOperator, @@ -1283,3 +1284,44 @@ def test_upload_compiled_sql_should_upload(mock_configure_remote, mock_object_st expected_dest_path = f"mock_remote_path/test_dag/compiled/{rel_path.lstrip('/')}" mock_object_storage_path.assert_any_call(expected_dest_path, conn_id="mock_conn_id") mock_object_storage_path.return_value.copy.assert_any_call(mock_object_storage_path.return_value) + + +@pytest.mark.integration +def test_clone_operator(caplog): + + with DAG("test-id-1", start_date=datetime(2022, 1, 1)) as dag: + seed_operator = DbtSeedLocalOperator( + profile_config=real_profile_config, + project_dir=DBT_PROJ_DIR, + task_id="seed", + dbt_cmd_flags=["--select", "raw_customers"], + install_deps=True, + append_env=True, + emit_datasets=False, + ) + run_operator = DbtRunLocalOperator( + profile_config=real_profile_config, + project_dir=DBT_PROJ_DIR, + task_id="run", + dbt_cmd_flags=["--models", "stg_customers"], + install_deps=True, + append_env=True, + emit_datasets=False, + ) + + clone_operator = DbtCloneLocalOperator( + profile_config=real_profile_config, + project_dir=DBT_PROJ_DIR, + task_id="clone", + dbt_cmd_flags=["--models", "stg_customers"], + install_deps=True, + append_env=True, + emit_datasets=False, + ) + + seed_operator >> run_operator >> clone_operator + + run_test_dag(dag) + + assert run_operator.inlets == [] + assert run_operator.outlets == []