Skip to content

Commit 65e4ffa

Browse files
committed
updated test related to file positional parameter
1 parent 58e2b21 commit 65e4ffa

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

tests/cli/commands/import/test_import_sbom.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ def test_sbom_command_happy_path(
8888
args = [
8989
'import',
9090
'sbom',
91-
'--file',
92-
temp_file_path,
9391
'--name',
9492
'test-sbom',
9593
'--vendor',
9694
'test-vendor',
95+
temp_file_path,
9796
]
9897
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
9998

@@ -122,8 +121,6 @@ def test_sbom_command_with_all_options(
122121
args = [
123122
'import',
124123
'sbom',
125-
'--file',
126-
temp_file_path,
127124
'--name',
128125
'test-sbom',
129126
'--vendor',
@@ -136,6 +133,7 @@ def test_sbom_command_with_all_options(
136133
137134
'--business-impact',
138135
'High',
136+
temp_file_path,
139137
]
140138
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
141139

@@ -155,29 +153,27 @@ def test_sbom_command_file_not_exists(self, mocker: 'MockerFixture') -> None:
155153
args = [
156154
'import',
157155
'sbom',
158-
'--file',
159-
non_existent_file,
160156
'--name',
161157
'test-sbom',
162158
'--vendor',
163159
'test-vendor',
160+
non_existent_file,
164161
]
165162
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
166163

167-
assert result.exit_code == 1
168-
assert 'No such file or directory' in result.output or 'FileNotFoundError' in result.output
164+
assert result.exit_code != 0
165+
assert "Invalid value for 'PATH': File " in result.output and 'not exist' in result.output
169166

170167
def test_sbom_command_file_is_directory(self, mocker: 'MockerFixture') -> None:
171168
with tempfile.TemporaryDirectory() as temp_dir:
172169
args = [
173170
'import',
174171
'sbom',
175-
'--file',
176-
temp_dir,
177172
'--name',
178173
'test-sbom',
179174
'--vendor',
180175
'test-vendor',
176+
temp_dir,
181177
]
182178
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
183179

@@ -205,14 +201,13 @@ def test_sbom_command_invalid_owner_email(
205201
args = [
206202
'import',
207203
'sbom',
208-
'--file',
209-
temp_file_path,
210204
'--name',
211205
'test-sbom',
212206
'--vendor',
213207
'test-vendor',
214208
'--owner',
215209
210+
temp_file_path,
216211
]
217212
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
218213

@@ -241,12 +236,11 @@ def test_sbom_command_http_400_error(
241236
args = [
242237
'import',
243238
'sbom',
244-
'--file',
245-
temp_file_path,
246239
'--name',
247240
'test-sbom',
248241
'--vendor',
249242
'test-vendor',
243+
temp_file_path,
250244
]
251245
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
252246

@@ -275,12 +269,11 @@ def test_sbom_command_http_500_error(
275269
args = [
276270
'import',
277271
'sbom',
278-
'--file',
279-
temp_file_path,
280272
'--name',
281273
'test-sbom',
282274
'--vendor',
283275
'test-vendor',
276+
temp_file_path,
284277
]
285278
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
286279

@@ -316,8 +309,6 @@ def test_sbom_command_multiple_owners(
316309
args = [
317310
'import',
318311
'sbom',
319-
'--file',
320-
temp_file_path,
321312
'--name',
322313
'test-sbom',
323314
'--vendor',
@@ -326,6 +317,7 @@ def test_sbom_command_multiple_owners(
326317
f'{username1}@example.com',
327318
'--owner',
328319
f'{username2}@example.com',
320+
temp_file_path,
329321
]
330322
result = CliRunner().invoke(app, args, env=CLI_ENV_VARS)
331323

0 commit comments

Comments
 (0)