forked from spdx/tools-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli.py
More file actions
71 lines (57 loc) · 1.95 KB
/
test_cli.py
File metadata and controls
71 lines (57 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-FileCopyrightText: 2023 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from importlib import resources
import pytest
from click.testing import CliRunner
from spdx_tools.spdx.clitools.pyspdxtools import main
@pytest.mark.parametrize(
"options",
[
("--infile", str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json"))),
("-i", str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json")), "--novalidation"),
(
"-i",
str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json")),
"--novalidation",
"--version",
"SPDX-2.3",
),
("-i", str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json")), "-o", "-"),
],
)
def test_cli_with_system_exit_code_0(options):
runner = CliRunner()
result = runner.invoke(main, options)
assert result.exit_code == 0
@pytest.mark.parametrize(
"options",
[
(
"-i",
str(
resources.files("tests.spdx.data.invalid").joinpath(
"spdx-trivy-vmware_log-intelligence-fluentd-"
"sha256_086af034f561f343f633be9d9f9e95f65ae6c61b8ddb2c6755ef5bb25b40f53a.json"
)
),
),
("-i", "non_existent_file.spdx"),
],
)
def test_cli_with_system_exit_code_1(options):
runner = CliRunner()
result = runner.invoke(main, options)
assert result.exit_code == 1
@pytest.mark.parametrize(
"options",
[
(),
("-i", str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json")), "--version"),
("-i", str(resources.files("tests.spdx.data").joinpath("SPDXJSONExample-v2.3.spdx.json")), "-o"),
],
)
def test_cli_with_system_exit_code_2(options):
runner = CliRunner()
result = runner.invoke(main, options)
assert result.exit_code == 2