import importlib
import os
import sys
import unittest
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
class TestArtifactPhrasesInSkill(unittest.TestCase):
def test_no_hardcoded_artifact_phrases_list(self):
import fetch_all_sources
self.assertFalse(
hasattr(fetch_all_sources, "_ARTIFACT_PHRASES"),
"_ARTIFACT_PHRASES must be deleted; Claude uses comprehension, not a keyword list"
)
def test_no_extract_related_artifacts_function(self):
import fetch_all_sources
self.assertFalse(
hasattr(fetch_all_sources, "extract_related_artifacts"),
"extract_related_artifacts() must be deleted; Claude reads content directly"
)
def test_rescan_reviewed_entries_importable(self):
from fetch_all_sources import rescan_reviewed_entries
self.assertTrue(callable(rescan_reviewed_entries))
def test_skill_references_check_related_gaps(self):
skill_path = os.path.join(
os.path.dirname(__file__), "..", "..",
".claude", "commands", "review-dfir-feeds.md"
)
with open(skill_path) as f:
content = f.read()
self.assertIn("check_related_gaps", content,
"skill must reference check_related_gaps()")
def test_skill_references_fetch_youtube_transcript(self):
skill_path = os.path.join(
os.path.dirname(__file__), "..", "..",
".claude", "commands", "review-dfir-feeds.md"
)
with open(skill_path) as f:
content = f.read()
self.assertIn("fetch_youtube_transcript", content,
"skill must reference fetch_youtube_transcript()")
def test_skill_does_not_mandate_keyword_list_for_claude(self):
skill_path = os.path.join(
os.path.dirname(__file__), "..", "..",
".claude", "commands", "review-dfir-feeds.md"
)
with open(skill_path) as f:
content = f.read()
self.assertNotIn(
"Pass it to `extract_related_artifacts()`", content,
"skill must not tell Claude to run the keyword scanner on fetched content"
)
def test_no_tilde_marker_in_skill(self):
skill_path = os.path.join(
os.path.dirname(__file__), "..", "..",
".claude", "commands", "review-dfir-feeds.md"
)
with open(skill_path) as f:
content = f.read()
self.assertNotIn(
"[~]", content,
"skill must not reference [~]; rescan_reviewed_entries() writes [ ] directly"
)
class TestRelatedGapDetection(unittest.TestCase):
def test_function_importable(self):
from fetch_all_sources import check_related_gaps
self.assertTrue(callable(check_related_gaps))
def test_returns_list(self):
from fetch_all_sources import check_related_gaps
result = check_related_gaps("shimcache", ["prefetch_dir", "amcache_hve"])
self.assertIsInstance(result, list)
def test_returns_missing_related(self):
from fetch_all_sources import check_related_gaps
result = check_related_gaps("shimcache", ["prefetch_dir", "amcache_hve"])
for item in result:
self.assertIsInstance(item, str)
def test_unknown_artifact_returns_empty(self):
from fetch_all_sources import check_related_gaps
result = check_related_gaps("this_does_not_exist_xyz", ["prefetch_dir"])
self.assertEqual(result, [])
def test_empty_co_occurring_returns_empty(self):
from fetch_all_sources import check_related_gaps
result = check_related_gaps("shimcache", [])
self.assertEqual(result, [])
def test_already_related_not_returned(self):
from fetch_all_sources import check_related_gaps
result = check_related_gaps("mft_file", ["mft_file"]) self.assertNotIn("mft_file", result)
class TestYouTubeTranscript(unittest.TestCase):
def test_function_importable(self):
from fetch_all_sources import fetch_youtube_transcript
self.assertTrue(callable(fetch_youtube_transcript))
def test_returns_str_or_none(self):
from fetch_all_sources import fetch_youtube_transcript
result = fetch_youtube_transcript("_3PiX4OT9pE")
self.assertTrue(result is None or isinstance(result, str),
f"expected str or None, got {type(result)}")
def test_nonexistent_video_returns_none(self):
from fetch_all_sources import fetch_youtube_transcript
result = fetch_youtube_transcript("AAAAAAAAAAAAAAAA_DOES_NOT_EXIST")
self.assertIsNone(result)
def test_transcript_contains_text_when_available(self):
from fetch_all_sources import fetch_youtube_transcript
result = fetch_youtube_transcript("_3PiX4OT9pE")
if result is not None:
self.assertGreater(len(result), 50,
"transcript should contain meaningful text")
def test_transcript_contains_dfir_terms_when_available(self):
from fetch_all_sources import fetch_youtube_transcript
result = fetch_youtube_transcript("_3PiX4OT9pE")
if result is not None:
self.assertIn("prefetch", result.lower(),
"Prefetch video transcript should contain 'prefetch'")
if __name__ == "__main__":
unittest.main()