Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /GRID-INTELLIGENCE_GRID /tests /misc /test_git_intelligence.py
| #!/usr/bin/env python3 | |
| import sys | |
| import unittest | |
| from pathlib import Path | |
| from unittest.mock import MagicMock, patch | |
| # Add scripts to path for git_intelligence module | |
| sys.path.insert(0, str(Path(__file__).parent.parent / "scripts")) | |
| try: | |
| from git_intelligence import ComplexityEstimator, OllamaClient | |
| except ModuleNotFoundError: | |
| raise unittest.SkipTest("Optional module 'git_intelligence' not available") | |
| class TestGitIntelligence(unittest.TestCase): | |
| def test_complexity_estimation_low(self): | |
| diff = "some small diff" | |
| staged = ["file1.py"] | |
| score = ComplexityEstimator.estimate(diff, staged) | |
| self.assertLessEqual(score, 3) | |
| self.assertEqual(ComplexityEstimator.select_model(score), "llama3.2:1b") | |
| def test_complexity_estimation_high(self): | |
| diff = "line\n" * 300 | |
| staged = ["file1.py", "file2.py", "file3.py", "file4.py", "file5.py"] | |
| score = ComplexityEstimator.estimate(diff, staged) | |
| self.assertGreater(score, 6) | |
| # score will be 3 (file_count) + 5 (diff_lines) = 8 | |
| self.assertEqual(ComplexityEstimator.select_model(score), "codellama:13b") | |
| def test_ollama_client_generate(self, mock_run): | |
| mock_run.return_value = MagicMock(returncode=0, stdout="AI Response", stderr="") | |
| client = OllamaClient() | |
| response = client.generate("test prompt") | |
| self.assertEqual(response, "AI Response") | |
| def test_ollama_client_unavailable(self, mock_run): | |
| mock_run.side_effect = FileNotFoundError() | |
| client = OllamaClient() | |
| response = client.generate("test prompt") | |
| self.assertIn("not installed", response) | |
| if __name__ == "__main__": | |
| unittest.main() | |
Xet Storage Details
- Size:
- 1.77 kB
- Xet hash:
- 43021ccd295c8e0a8a01757cc5155c22efb2f0e8ef55b40f01fb8c3f0bdcf0bb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.