CI / test (push) Canceled after 0s
## Summary epic r04 - begin refactor ## Change Type - [x] Cowork feature - [ ] Bug fix - [ ] Core AI contribution - [ ] Test / hardening - [ ] Performance - [ ] Documentation ## Related Work Cowork Task: Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets Core AI Issue: Core Task: Related PR: ## Scope What is intentionally included? What is intentionally NOT included? ## Validation - [ ] Unit tests - [ ] Integration tests - [ ] Manual verification - [ ] Regression check Commands / evidence: ## Security Impact Permission / credential / network / customer data impact: ## Compatibility - [ ] No breaking change - [ ] Breaking change documented ## Reviewer Notes Anything Cowork reviewers should pay attention to. --------- Co-authored-by: Anh Tran Nguyen Minh <anhtnm1@fpt.com> Co-authored-by: Huong Le Thi Thien <huongltt35@fpt.com> Co-authored-by: Nam Pham Dinh Thanh <nampdt@fpt.com> Co-authored-by: Vu Dam Tuan <vudt15@fpt.com> Co-authored-by: Hiep Ha Van <hiephv3@fpt.com> Co-authored-by: Lam Hoang Van <lamhv7@fpt.com> Reviewed-on: #7 Co-authored-by: Duy Le Huu <duylh19@fpt.com>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
"""EPIC R08-T14: graph_index_service.py — pure helpers moved out of
|
|
ui/structure_graph_view.py, no Qt.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from cowork_local.application.workspaces.graph_index_service import extract_file_contents
|
|
|
|
|
|
def test_extract_file_contents_reads_text_files(tmp_path):
|
|
f = tmp_path / "a.py"
|
|
f.write_text("print('hello')\n", encoding="utf-8")
|
|
|
|
block, cache = extract_file_contents([str(f)], {}, str(tmp_path))
|
|
|
|
assert "print('hello')" in block
|
|
assert str(f) in cache
|
|
assert cache[str(f)]
|
|
|
|
|
|
def test_extract_file_contents_reuses_the_cache(tmp_path):
|
|
f = tmp_path / "a.txt"
|
|
f.write_text("original", encoding="utf-8")
|
|
seed_cache = {str(f): "cached content, not re-read"}
|
|
|
|
block, cache = extract_file_contents([str(f)], seed_cache, str(tmp_path))
|
|
|
|
assert "cached content, not re-read" in block
|
|
|
|
|
|
def test_extract_file_contents_skips_unreadable_paths_without_raising(tmp_path):
|
|
missing = tmp_path / "does-not-exist.txt"
|
|
block, cache = extract_file_contents([str(missing)], {}, str(tmp_path))
|
|
assert block == ""
|
|
|
|
|
|
def test_extract_file_contents_respects_max_total_budget(tmp_path):
|
|
f1 = tmp_path / "a.txt"
|
|
f1.write_text("x" * 100, encoding="utf-8")
|
|
f2 = tmp_path / "b.txt"
|
|
f2.write_text("y" * 100, encoding="utf-8")
|
|
|
|
block, cache = extract_file_contents([str(f1), str(f2)], {}, str(tmp_path), max_total=50)
|
|
|
|
assert len(block) < 250 # bounded, not both files in full
|