From abe8f2ae73303ef28f04b38f9a7d4e020b8a9ae0 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Fri, 13 Feb 2026 22:15:48 -0500 Subject: [PATCH] fix: resolve CI test failures in ollama and hashview tests - Mock rulesDirectory in ollama test fixture so hcatOllama doesn't fail with FileNotFoundError on CI where /path/to/hashcat/rules doesn't exist - Mock potfile path in hashview auto-merge test so found file cleanup isn't blocked by missing ~/.hashcat directory - Update pre-push hook to match CI env vars (HATE_CRACK_SKIP_INIT=1) Co-Authored-By: Claude Opus 4.6 --- tests/test_hashview.py | 4 ++++ tests/test_pull_ollama_model.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/tests/test_hashview.py b/tests/test_hashview.py index 53ac183..8a1df3c 100644 --- a/tests/test_hashview.py +++ b/tests/test_hashview.py @@ -587,6 +587,10 @@ class TestHashviewAPI: # Set up session.get to return different responses api.session.get.side_effect = [mock_left_response, mock_found_response] + # Mock potfile path so cleanup isn't blocked by missing ~/.hashcat dir + potfile = str(tmp_path / "hashcat.potfile") + monkeypatch.setattr("hate_crack.api.get_hcat_potfile_path", lambda: potfile) + # Download left hashes (should auto-download and split found for hashcat) left_file = tmp_path / "left_1_2.txt" result = api.download_left_hashes(1, 2, output_file=str(left_file)) diff --git a/tests/test_pull_ollama_model.py b/tests/test_pull_ollama_model.py index 43b0d07..4d3cb6e 100644 --- a/tests/test_pull_ollama_model.py +++ b/tests/test_pull_ollama_model.py @@ -42,12 +42,15 @@ def ollama_env(tmp_path): @contextmanager def ollama_globals(tmp_path, tuning="", potfile=""): """Patch the hc_main globals that hcatOllama reads.""" + rules_dir = str(tmp_path / "rules") + os.makedirs(rules_dir, exist_ok=True) with mock.patch.object(hc_main, "ollamaUrl", OLLAMA_URL), \ mock.patch.object(hc_main, "ollamaModel", MODEL), \ mock.patch.object(hc_main, "hcatBin", "/usr/bin/hashcat"), \ mock.patch.object(hc_main, "hcatTuning", tuning), \ mock.patch.object(hc_main, "hcatPotfilePath", potfile), \ mock.patch.object(hc_main, "hate_path", str(tmp_path)), \ + mock.patch.object(hc_main, "rulesDirectory", rules_dir), \ mock.patch("hate_crack.main.generate_session_id", return_value="test_session"): yield