Skip to content

Conversation

@sfc-gh-jwilkowski
Copy link
Contributor

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.
  • I've described my changes in the documentation.

Changes description

...

@sfc-gh-jwilkowski sfc-gh-jwilkowski force-pushed the jw/SNOW-2326970-dcm-test-command branch 5 times, most recently from c04bc02 to 216c405 Compare October 17, 2025 09:13
@sfc-gh-jwilkowski sfc-gh-jwilkowski force-pushed the jw/SNOW-2326970-dcm-test-command branch from 216c405 to 1abd3af Compare October 17, 2025 09:52
Comment on lines +387 to 427
@mock.patch(execute_queries)
def test_plan_project_with_output_path__stage(mock_execute_query, project_directory):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="@output_stage/results",
)

mock_execute_query.assert_called_once_with(
query="EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @output_stage/results"
)


@mock.patch(execute_queries)
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.get_recursive")
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.create")
def test_plan_project_with_output_path__local_path(
mock_create,
mock_get_recursive,
mock_execute_query,
project_directory,
mock_from_resource,
):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="output_path/results",
)

temp_stage_fqn = mock_from_resource()
mock_execute_query.assert_called_once_with(
query=f"EXECUTE DCM PROJECT IDENTIFIER('my_project') DEPLOY AS \"v1\" FROM @test_stage"
query=f"EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @{temp_stage_fqn}"
)
mock_create.assert_called_once_with(temp_stage_fqn, temporary=True)
mock_get_recursive.assert_called_once_with(
stage_path=str(temp_stage_fqn), dest_path=Path("output_path/results")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be a duplicate test case in the code. The test test_plan_project_with_output_path__stage is defined twice - once after test_analyze_project_with_various_options and again later in the file. This duplication could cause confusion during maintenance and potentially lead to unexpected test behavior.

Consider removing one of the duplicate tests or renaming them to clarify their distinct purposes if they're testing different scenarios.

Suggested change
@mock.patch(execute_queries)
def test_plan_project_with_output_path__stage(mock_execute_query, project_directory):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="@output_stage/results",
)
mock_execute_query.assert_called_once_with(
query="EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @output_stage/results"
)
@mock.patch(execute_queries)
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.get_recursive")
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.create")
def test_plan_project_with_output_path__local_path(
mock_create,
mock_get_recursive,
mock_execute_query,
project_directory,
mock_from_resource,
):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="output_path/results",
)
temp_stage_fqn = mock_from_resource()
mock_execute_query.assert_called_once_with(
query=f"EXECUTE DCM PROJECT IDENTIFIER('my_project') DEPLOY AS \"v1\" FROM @test_stage"
query=f"EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @{temp_stage_fqn}"
)
mock_create.assert_called_once_with(temp_stage_fqn, temporary=True)
mock_get_recursive.assert_called_once_with(
stage_path=str(temp_stage_fqn), dest_path=Path("output_path/results")
)
@mock.patch(execute_queries)
def test_plan_project_with_stage_output_path(mock_execute_query, project_directory):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="@output_stage/results",
)
mock_execute_query.assert_called_once_with(
query="EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @output_stage/results"
)
@mock.patch(execute_queries)
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.get_recursive")
@mock.patch("snowflake.cli._plugins.dbt.manager.StageManager.create")
def test_plan_project_with_output_path__local_path(
mock_create,
mock_get_recursive,
mock_execute_query,
project_directory,
mock_from_resource,
):
mgr = DCMProjectManager()
mgr.plan(
project_identifier=TEST_PROJECT,
from_stage="@test_stage",
configuration="some_configuration",
output_path="output_path/results",
)
temp_stage_fqn = mock_from_resource()
mock_execute_query.assert_called_once_with(
query=f"EXECUTE DCM PROJECT IDENTIFIER('my_project') PLAN USING CONFIGURATION some_configuration FROM @test_stage OUTPUT_PATH @{temp_stage_fqn}"
)
mock_create.assert_called_once_with(temp_stage_fqn, temporary=True)
mock_get_recursive.assert_called_once_with(
stage_path=str(temp_stage_fqn), dest_path=Path("output_path/results")
)

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants