import unittest from pathlib import Path from app import workspace class WorkspaceSearchTests(unittest.TestCase): def test_search_excerpt_returns_numbered_matching_lines_from_deep_in_file(self) -> None: project_root = Path(__file__).resolve().parents[1] results = workspace.retrieve("timeout_seconds=600.0", project_root, limit=10) path, excerpt = next( (path, excerpt) for path, excerpt in results if path == "app/main.py" ) self.assertRegex(excerpt, r"\d+: .*timeout_seconds=600\.0") self.assertNotIn("from __future__ import annotations", excerpt) def test_search_ranks_requested_flutter_timeout_code_before_docs(self) -> None: project_root = Path(__file__).resolve().parents[1] results = workspace.retrieve( "مهلة عميل Flutter لمسار run/stream", project_root, limit=3 ) path, excerpt = results[0] self.assertEqual(path, "flutter_app/lib/core/network/api_repository.dart") self.assertIn("minutes: 10", excerpt) if __name__ == "__main__": unittest.main()