Skip to content

Commit c79c929

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

File tree

5 files changed

+66
-10
lines changed

5 files changed

+66
-10
lines changed

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

+25-5
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,14 @@ 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+
134+
assert "Results: " in result.output and " license policy" in result.output
135+
124136
# Change the values in the config file
125137
policy_config_file_path = create_license_policy_config_file(
126138
directory=tmp_path,
@@ -139,7 +151,11 @@ def test_license_policy_commands(runner, organization, tmp_path):
139151
catch_exceptions=False,
140152
)
141153
assert (
142-
"Updating " + slug_perm + " license policy in the cloudsmith namespace ...OK"
154+
"Updating "
155+
+ slug_perm
156+
+ " license policy in the "
157+
+ organization
158+
+ " namespace ...OK"
143159
in result.output
144160
)
145161
assert_output_matches_policy_config(result.output, policy_config_file_path)
@@ -151,7 +167,9 @@ def test_license_policy_commands(runner, organization, tmp_path):
151167
assert (
152168
"Are you absolutely certain you want to delete the "
153169
+ slug_perm
154-
+ " license policy from the cloudsmith namespace? [y/N]: N"
170+
+ " license policy from the "
171+
+ organization
172+
+ " namespace? [y/N]: N"
155173
in result.output
156174
)
157175
assert "OK, phew! Close call. :-)" in result.output
@@ -163,10 +181,12 @@ def test_license_policy_commands(runner, organization, tmp_path):
163181
assert (
164182
"Are you absolutely certain you want to delete the "
165183
+ slug_perm
166-
+ " license policy from the cloudsmith namespace? [y/N]: Y"
184+
+ " license policy from the "
185+
+ organization
186+
+ " namespace? [y/N]: Y"
167187
in result.output
168188
)
169189
assert (
170-
"Deleting " + slug_perm + " from the cloudsmith namespace ... OK"
190+
"Deleting " + slug_perm + " from the " + organization + " namespace ... OK"
171191
in result.output
172192
)

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

+19-5
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(
@@ -124,6 +126,12 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
124126
result = runner.invoke(ls, args=[organization], catch_exceptions=False)
125127
assert "Getting vulnerability policies ... OK" in result.output
126128
assert_output_matches_policy_config(result.output, policy_config_file_path)
129+
# List policies with --show-all flag
130+
result = runner.invoke(
131+
ls, args=[organization, "--show-all"], catch_exceptions=False
132+
)
133+
assert "Getting vulnerability policies ... OK" in result.output
134+
assert "Results: " in result.output and " vulnerability policy" in result.output
127135

128136
# Change the values in the config file
129137
policy_config_file_path = create_vulnerability_policy_config_file(
@@ -145,7 +153,9 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
145153
assert (
146154
"Updating "
147155
+ slug_perm
148-
+ " vulnerability policy in the cloudsmith namespace ...OK"
156+
+ " vulnerability policy in the "
157+
+ organization
158+
+ " namespace ...OK"
149159
in result.output
150160
)
151161
assert_output_matches_policy_config(result.output, policy_config_file_path)
@@ -157,7 +167,9 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
157167
assert (
158168
"Are you absolutely certain you want to delete the "
159169
+ slug_perm
160-
+ " vulnerability policy from the cloudsmith namespace? [y/N]: N"
170+
+ " vulnerability policy from the "
171+
+ organization
172+
+ " namespace? [y/N]: N"
161173
in result.output
162174
)
163175
assert "OK, phew! Close call. :-)" in result.output
@@ -169,10 +181,12 @@ def test_vulnerability_policy_commands(runner, organization, tmp_path):
169181
assert (
170182
"Are you absolutely certain you want to delete the "
171183
+ slug_perm
172-
+ " vulnerability policy from the cloudsmith namespace? [y/N]: Y"
184+
+ " vulnerability policy from the "
185+
+ organization
186+
+ " namespace? [y/N]: Y"
173187
in result.output
174188
)
175189
assert (
176-
"Deleting " + slug_perm + " from the cloudsmith namespace ... OK"
190+
"Deleting " + slug_perm + " from the " + organization + " namespace ... OK"
177191
in result.output
178192
)

cloudsmith_cli/cli/tests/commands/test_package_commands.py

+7
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

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ 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+
# A static number cannot be used here because we are performing this test in cloudsmith org which is active.
126+
assert "Results: " in result.output and " repository" in result.output
127+
122128
# Change the repository description in the repo config file.
123129
repository_description = random_str()
124130
repo_config_file_path = create_repo_config_file(

cloudsmith_cli/cli/tests/commands/test_upstream.py

+9
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)