Skip to content

Commit 1cea1b6

Browse files
committed
Modified test to include new flags
1 parent cc200df commit 1cea1b6

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

integration_tests/test_program.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import subprocess
2+
from pathlib import Path
3+
4+
import pytest
5+
from sarif_pydantic.sarif import Run, Sarif, Tool, ToolDriver
26

37
from core_codemods.remove_assertion_in_pytest_raises import (
48
RemoveAssertionInPytestRaises,
@@ -26,14 +30,50 @@ def test_codemods_include_exclude_conflict(self):
2630
)
2731
assert completed_process.returncode == 3
2832

29-
def test_load_sast_only_by_flag(self, tmp_path):
33+
@pytest.mark.parametrize(
34+
"cli_args",
35+
[
36+
"--sonar-issues-json",
37+
"--sonar-hotspots-json",
38+
"--sonar-json",
39+
],
40+
)
41+
def test_load_sast_only_by_sonar_flag(self, tmp_path, cli_args):
3042
tmp_file_path = tmp_path / "sonar.json"
3143
tmp_file_path.touch()
3244
completed_process = subprocess.run(
3345
[
3446
"codemodder",
3547
"tests/samples/",
36-
"--sonar-issues-json",
48+
cli_args,
49+
f"{tmp_file_path}",
50+
"--dry-run",
51+
],
52+
check=False,
53+
capture_output=True,
54+
text=True,
55+
)
56+
print(completed_process.stdout)
57+
print(completed_process.stderr)
58+
assert completed_process.returncode == 0
59+
assert RemoveAssertionInPytestRaises.id not in completed_process.stdout
60+
61+
def test_load_sast_only_by_sarif_flag(self, tmp_path: Path):
62+
tmp_file_path = tmp_path / "sarif.json"
63+
sarif_run = Run(
64+
tool=Tool(driver=ToolDriver(name="test")),
65+
results=[],
66+
)
67+
sarif = Sarif(runs=[sarif_run], **{"$schema": ""})
68+
tmp_file_path.write_text(
69+
sarif.model_dump_json(indent=2, exclude_none=True, by_alias=True)
70+
)
71+
72+
completed_process = subprocess.run(
73+
[
74+
"codemodder",
75+
"tests/samples/",
76+
"--sarif",
3777
f"{tmp_file_path}",
3878
"--dry-run",
3979
],

0 commit comments

Comments
 (0)