Skip to content

Commit 43e71ae

Browse files
fix: [SNOW-2032682] fix project entity_id vs identifier (#2191)
1 parent 4a263e1 commit 43e71ae

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

src/snowflake/cli/_plugins/project/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ def add_version(
187187

188188
@app.command(requires_connection=True)
189189
def list_versions(
190-
entity_id: str = entity_argument("project", required=True), **options
190+
identifier: FQN = project_identifier,
191+
**options,
191192
):
192193
"""
193194
Lists versions of given project.
194195
"""
195196
pm = ProjectManager()
196-
results = pm.list_versions(project_name=FQN.from_string(entity_id))
197+
results = pm.list_versions(project_name=identifier)
197198
return QueryResult(results)

tests/__snapshots__/test_help_messages.ambr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6765,13 +6765,14 @@
67656765
# name: test_help_messages[project.list-versions]
67666766
'''
67676767

6768-
Usage: root project list-versions [OPTIONS] ENTITY_ID
6768+
Usage: root project list-versions [OPTIONS] IDENTIFIER
67696769

67706770
Lists versions of given project.
67716771

67726772
+- Arguments ------------------------------------------------------------------+
6773-
| * entity_id TEXT ID of project entity. |
6774-
| [required] |
6773+
| * identifier TEXT Identifier of the project; for example: |
6774+
| MY_PROJECT |
6775+
| [required] |
67756776
+------------------------------------------------------------------------------+
67766777
+- Options --------------------------------------------------------------------+
67776778
| --help -h Show this message and exit. |

tests_integration/test_data/projects/dcm_project/snowflake.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ entities:
33
my_project:
44
type: project
55
stage: "my_project_stage"
6+
identifier: "project_descriptive_name"
67
artifacts:
78
- file_a.sql

tests_integration/test_dcm_project.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ def test_project_deploy(
3939
test_database,
4040
project_directory,
4141
):
42-
project_name = "my_project"
42+
project_name = "project_descriptive_name"
43+
entity_id = "my_project"
4344
with project_directory("dcm_project"):
44-
result = runner.invoke_with_connection(["project", "create"])
45+
result = runner.invoke_with_connection(["project", "create", entity_id])
4546
assert result.exit_code == 0, result.output
4647
assert (
47-
"Project 'my_project' successfully created and initial version is added."
48+
f"Project '{project_name}' successfully created and initial version is added."
4849
in result.output
4950
)
5051
# project should be initialized with a version
@@ -69,7 +70,7 @@ def test_project_deploy(
6970
[
7071
"project",
7172
"execute",
72-
"my_project",
73+
project_name,
7374
"-D",
7475
f"table_name='{test_database}.PUBLIC.MyTable'",
7576
]
@@ -81,13 +82,13 @@ def test_project_deploy(
8182
"project",
8283
"list",
8384
"--like",
84-
"MY_PROJECT",
85+
project_name,
8586
]
8687
)
8788
assert result.exit_code == 0, result.output
8889
assert len(result.json) == 1
8990
project = result.json[0]
90-
assert project["name"].lower() == "my_project".lower()
91+
assert project["name"].lower() == project_name.lower()
9192

9293

9394
@pytest.mark.integration
@@ -97,7 +98,7 @@ def test_create_corner_cases(
9798
test_database,
9899
project_directory,
99100
):
100-
project_name = "my_project"
101+
project_name = "project_descriptive_name"
101102
stage_name = "my_project_stage"
102103
with project_directory("dcm_project"):
103104
# case 1: stage already exists
@@ -132,7 +133,8 @@ def test_project_add_version(
132133
test_database,
133134
project_directory,
134135
):
135-
project_name = "my_project"
136+
project_name = "project_descriptive_name"
137+
entity_id = "my_project"
136138
default_stage_name = "my_project_stage"
137139
other_stage_name = "other_project_stage"
138140

@@ -177,7 +179,7 @@ def test_project_add_version(
177179
[
178180
"project",
179181
"add-version",
180-
project_name,
182+
entity_id,
181183
"--from",
182184
f"@{other_stage_name}",
183185
"--alias",

0 commit comments

Comments
 (0)