Skip to content

Commit 3452270

Browse files
Add tests for --show-all flag
1 parent ed7b665 commit 3452270

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

cloudsmith_cli/cli/tests/commands/policy/test_licence.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ def test_license_policy_commands(runner, organization, tmp_path):
109109
catch_exceptions=False,
110110
)
111111
assert (
112-
"Creating " + policy_name + " license policy for the cloudsmith namespace ...OK"
112+
"Creating "
113+
+ policy_name
114+
+ " license policy for the "
115+
+ organization
116+
+ " namespace ...OK"
113117
in result.output
114118
)
115119
slug_perm = assert_output_matches_policy_config(
@@ -121,6 +125,13 @@ def test_license_policy_commands(runner, organization, tmp_path):
121125
assert "Getting license policies ... OK" in result.output
122126
assert_output_matches_policy_config(result.output, policy_config_file_path)
123127

128+
# List policies with --show-all flag
129+
result = runner.invoke(
130+
ls, args=[organization, "--show-all"], catch_exceptions=False
131+
)
132+
assert "Getting license policies ... OK" in result.output
133+
assert "Results: 1 license policy" in result.output
134+
124135
# Change the values in the config file
125136
policy_config_file_path = create_license_policy_config_file(
126137
directory=tmp_path,
@@ -139,7 +150,11 @@ def test_license_policy_commands(runner, organization, tmp_path):
139150
catch_exceptions=False,
140151
)
141152
assert (
142-
"Updating " + slug_perm + " license policy in the cloudsmith namespace ...OK"
153+
"Updating "
154+
+ slug_perm
155+
+ " license policy in the "
156+
+ organization
157+
+ " namespace ...OK"
143158
in result.output
144159
)
145160
assert_output_matches_policy_config(result.output, policy_config_file_path)
@@ -151,7 +166,9 @@ def test_license_policy_commands(runner, organization, tmp_path):
151166
assert (
152167
"Are you absolutely certain you want to delete the "
153168
+ slug_perm
154-
+ " license policy from the cloudsmith namespace? [y/N]: N"
169+
+ " license policy from the "
170+
+ organization
171+
+ " namespace? [y/N]: N"
155172
in result.output
156173
)
157174
assert "OK, phew! Close call. :-)" in result.output
@@ -163,10 +180,12 @@ def test_license_policy_commands(runner, organization, tmp_path):
163180
assert (
164181
"Are you absolutely certain you want to delete the "
165182
+ slug_perm
166-
+ " license policy from the cloudsmith namespace? [y/N]: Y"
183+
+ " license policy from the "
184+
+ organization
185+
+ " namespace? [y/N]: Y"
167186
in result.output
168187
)
169188
assert (
170-
"Deleting " + slug_perm + " from the cloudsmith namespace ... OK"
189+
"Deleting " + slug_perm + " from the " + organization + " namespace ... OK"
171190
in result.output
172191
)

cloudsmith_cli/cli/tests/commands/policy/test_vulnerability.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
113113
assert (
114114
"Creating "
115115
+ policy_name
116-
+ " vulnerability policy for the cloudsmith namespace ...OK"
116+
+ " vulnerability policy for the "
117+
+ organization
118+
+ " namespace ...OK"
117119
in result.output
118120
)
119121
slug_perm = assert_output_matches_policy_config(
@@ -125,6 +127,13 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
125127
assert "Getting vulnerability policies ... OK" in result.output
126128
assert_output_matches_policy_config(result.output, policy_config_file_path)
127129

130+
# List policies with --show-all flag
131+
result = runner.invoke(
132+
ls, args=[organization, "--show-all"], catch_exceptions=False
133+
)
134+
assert "Getting vulnerability policies ... OK" in result.output
135+
assert "Results: 1 vulnerability policy" in result.output
136+
128137
# Change the values in the config file
129138
policy_config_file_path = create_vulnerability_policy_config_file(
130139
directory=tmp_path,
@@ -145,7 +154,9 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
145154
assert (
146155
"Updating "
147156
+ slug_perm
148-
+ " vulnerability policy in the cloudsmith namespace ...OK"
157+
+ " vulnerability policy in the "
158+
+ organization
159+
+ " namespace ...OK"
149160
in result.output
150161
)
151162
assert_output_matches_policy_config(result.output, policy_config_file_path)
@@ -157,7 +168,9 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
157168
assert (
158169
"Are you absolutely certain you want to delete the "
159170
+ slug_perm
160-
+ " vulnerability policy from the cloudsmith namespace? [y/N]: N"
171+
+ " vulnerability policy from the "
172+
+ organization
173+
+ " namespace? [y/N]: N"
161174
in result.output
162175
)
163176
assert "OK, phew! Close call. :-)" in result.output
@@ -169,10 +182,12 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
169182
assert (
170183
"Are you absolutely certain you want to delete the "
171184
+ slug_perm
172-
+ " vulnerability policy from the cloudsmith namespace? [y/N]: Y"
185+
+ " vulnerability policy from the "
186+
+ organization
187+
+ " namespace? [y/N]: Y"
173188
in result.output
174189
)
175190
assert (
176-
"Deleting " + slug_perm + " from the cloudsmith namespace ... OK"
191+
"Deleting " + slug_perm + " from the " + organization + " namespace ... OK"
177192
in result.output
178193
)

cloudsmith_cli/cli/tests/commands/test_package_commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ def test_push_and_delete_raw_package(
5050
small_file_data = data[0]
5151
assert small_file_data["filename"] == pkg_file.name
5252

53+
# List packages with --show-all flag
54+
result = runner.invoke(
55+
list_, args=["pkgs", org_repo, "--show-all"], catch_exceptions=False
56+
)
57+
assert "Getting list of packages ... OK" in result.output
58+
assert "Results: 1 package retrieved" in result.output
59+
5360
# Wait for the package to sync.
5461
org_repo_package = f"{org_repo}/{small_file_data['slug']}"
5562
for _ in range(10):

cloudsmith_cli/cli/tests/commands/test_repos.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def test_repos_commands(runner, organization, tmp_path):
119119
result.output, organization, repo_config_file_path
120120
)
121121

122+
# List repositories with --show-all flag
123+
result = runner.invoke(get, [organization, "--show-all"], catch_exceptions=False)
124+
assert "Getting list of repositories ... OK" in result.output
125+
assert "Results: 1 repository retrieved" in result.output
126+
122127
# Change the repository description in the repo config file.
123128
repository_description = random_str()
124129
repo_config_file_path = create_repo_config_file(

cloudsmith_cli/cli/tests/commands/test_upstream.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ def test_upstream_commands(
7171
assert result_data["name"] == upstream_config["name"]
7272
assert result_data["upstream_url"] == upstream_config["upstream_url"]
7373

74+
# List upstreams with --show-all flag
75+
result = runner.invoke(
76+
upstream,
77+
args=[upstream_format, "ls", org_repo, "--show-all"],
78+
catch_exceptions=False,
79+
)
80+
assert "Getting upstreams... OK" in result.output
81+
assert "Results: 1 upstream" in result.output
82+
7483
slug_perm = result_data["slug_perm"]
7584
assert slug_perm
7685
org_repo_slug_perm = f"{org_repo}/{slug_perm}"

0 commit comments

Comments
 (0)