Skip to content

Commit 35eaaac

Browse files
committed
Add YAML export test
1 parent 6fada83 commit 35eaaac

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/test_config.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@
4040

4141
def __test_config_cmd(arguments: list[str]) -> None:
4242
"""Runs a test command"""
43-
util.clean(util.JSON_FILE)
43+
outputfile = arguments[arguments.index(f"-{opt.REPORT_FILE_SHORT}") + 1]
44+
util.clean(outputfile)
4445
with pytest.raises(SystemExit) as e:
4546
with patch.object(sys, "argv", arguments):
4647
config.main()
4748
assert int(str(e.value)) == errcodes.OK
48-
assert util.file_not_empty(util.JSON_FILE)
49-
util.clean(util.JSON_FILE)
49+
assert util.file_not_empty(outputfile)
50+
util.clean(outputfile)
5051

5152

5253
def test_config_export() -> None:
@@ -74,6 +75,11 @@ def test_config_export_partial_3() -> None:
7475
__test_config_cmd(OPTS + ["-w", "projects", f"-{opt.KEYS_SHORT}", "okorach_sonar-tools"])
7576

7677

78+
def test_config_export_yaml() -> None:
79+
"""test_config_export_partial_3"""
80+
__test_config_cmd([CMD] + util.STD_OPTS + ["-e", f"-{opt.REPORT_FILE_SHORT}", util.YAML_FILE])
81+
82+
7783
def test_config_export_wrong() -> None:
7884
"""test_config_export_wrong"""
7985
util.clean(util.JSON_FILE)

test/utilities.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
CSV_FILE = "temp.csv"
3838
JSON_FILE = "temp.json"
39+
YAML_FILE = "temp.yaml"
3940

4041
STD_OPTS = [f"-{opt.URL_SHORT}", os.getenv("SONAR_HOST_URL"), f"-{opt.TOKEN_SHORT}", os.getenv("SONAR_TOKEN_ADMIN_USER")]
4142
TEST_OPTS = [f"-{opt.URL_SHORT}", LATEST_TEST, f"-{opt.TOKEN_SHORT}", os.getenv("SONAR_TOKEN_ADMIN_USER")]

0 commit comments

Comments
 (0)