Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Modified test to include new flags
  • Loading branch information
andrecsilva committed Jun 30, 2025
commit 1cea1b61f0199a6f5239d58f945e5cecc2cc14c9
44 changes: 42 additions & 2 deletions integration_tests/test_program.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import subprocess
from pathlib import Path

import pytest
from sarif_pydantic.sarif import Run, Sarif, Tool, ToolDriver

from core_codemods.remove_assertion_in_pytest_raises import (
RemoveAssertionInPytestRaises,
Expand Down Expand Up @@ -26,14 +30,50 @@ def test_codemods_include_exclude_conflict(self):
)
assert completed_process.returncode == 3

def test_load_sast_only_by_flag(self, tmp_path):
@pytest.mark.parametrize(
"cli_args",
[
"--sonar-issues-json",
"--sonar-hotspots-json",
"--sonar-json",
],
)
def test_load_sast_only_by_sonar_flag(self, tmp_path, cli_args):
tmp_file_path = tmp_path / "sonar.json"
tmp_file_path.touch()
completed_process = subprocess.run(
[
"codemodder",
"tests/samples/",
"--sonar-issues-json",
cli_args,
f"{tmp_file_path}",
"--dry-run",
],
check=False,
capture_output=True,
text=True,
)
print(completed_process.stdout)
print(completed_process.stderr)
assert completed_process.returncode == 0
assert RemoveAssertionInPytestRaises.id not in completed_process.stdout

def test_load_sast_only_by_sarif_flag(self, tmp_path: Path):
tmp_file_path = tmp_path / "sarif.json"
sarif_run = Run(
tool=Tool(driver=ToolDriver(name="test")),
results=[],
)
sarif = Sarif(runs=[sarif_run], **{"$schema": ""})
tmp_file_path.write_text(
sarif.model_dump_json(indent=2, exclude_none=True, by_alias=True)
)

completed_process = subprocess.run(
[
"codemodder",
"tests/samples/",
"--sarif",
f"{tmp_file_path}",
"--dry-run",
],
Expand Down