-
Notifications
You must be signed in to change notification settings - Fork 79
Jw/snow 2326970 dcm test command #2654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c04bc02 to
216c405
Compare
216c405 to
1abd3af
Compare
| @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") | ||
| ) |
There was a problem hiding this comment.
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.
| @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
Is this helpful? React 👍 or 👎 to let us know.
Pre-review checklist
Changes description
...