-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathtest_scanner_integration.py
More file actions
35 lines (28 loc) · 1.1 KB
/
test_scanner_integration.py
File metadata and controls
35 lines (28 loc) · 1.1 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
import csv
import os
import subprocess
import pytest
def test_integration_scan(tmp_path):
# Paths to real tools
scanner_path = os.path.abspath("version_scanner.py")
config_path = os.path.abspath("regex_config.yaml")
# Static data directory (which we haven't created yet!)
data_dir = os.path.abspath("tests/data")
# Run the scanner in the tmp_path so the output file is created there
cmd = [
"python3", scanner_path,
"-d", "python",
"-v", "3.7",
"-p", data_dir,
"--config", config_path,
"-o", "scanner_report.csv"
]
# This will fail because tests/data doesn't exist or is empty!
result = subprocess.run(cmd, cwd=tmp_path, capture_output=True, text=True)
report_file = tmp_path / "scanner_report.csv"
assert report_file.exists(), f"Report file not found. Stderr: {result.stderr}"
with open(report_file, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f)
rows = list(reader)
# We expect at least some matches when we build the data directory
assert len(rows) > 0