feat(mindmodel): add checks utilities and tests

This commit is contained in:
2026-03-24 21:26:38 +01:00
parent 2efd7ba3a0
commit 7bd7d0d18c
2 changed files with 115 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import os
import tempfile
from scripts.mindmodel import checks
def test_file_exists(tmp_path):
# create a file under tmp_path
base = str(tmp_path)
p = tmp_path / "subdir"
p.mkdir()
f = p / "file.txt"
f.write_text("hello")
# path relative to base
assert checks.file_exists(base, "subdir/file.txt")
# non-existing
assert not checks.file_exists(base, "subdir/missing.txt")
def test_detect_truncated():
assert checks.detect_truncated("This is a truncated snippet...")
assert checks.detect_truncated("Truncation marker: [truncated]")
assert checks.detect_truncated("contains truncatED word")
assert not checks.detect_truncated("This is complete")
assert not checks.detect_truncated("")
def test_find_potential_secrets():
text = """
api_key = "abcdEFGH1234ijklMNOP"
password: 'hunter2'
aws = AKIA1234567890ABCD12
random_hex = deadbeefdeadbeefdeadbeefdeadbeef
not_a_secret = short
"""
found = checks.find_potential_secrets(text)
# should find api_key value, password, aws and long hex
assert "abcdEFGH1234ijklMNOP" in found
assert "hunter2" in found
assert any(item.startswith("AKIA") for item in found)
assert any("deadbeef" in item for item in found)