fix(retrieval): accept generated Python bytecode cache
CI / Capabilities and shell quality (push) Successful in 12s
CI / Python tests and compilation (push) Successful in 25s
CI / CI configuration security checks (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 14s
CI / PowerShell tests on Ubuntu (push) Successful in 1m14s
CI / Bash integration and installation guards (push) Successful in 1m38s
CI / Installed client configuration smoke tests (push) Successful in 14s
CI / Qwen retrieval integration (push) Successful in 14m18s
CI / Capabilities and shell quality (push) Successful in 12s
CI / Python tests and compilation (push) Successful in 25s
CI / CI configuration security checks (push) Successful in 5s
CI / Build and inspect generated packages (push) Successful in 14s
CI / PowerShell tests on Ubuntu (push) Successful in 1m14s
CI / Bash integration and installation guards (push) Successful in 1m38s
CI / Installed client configuration smoke tests (push) Successful in 14s
CI / Qwen retrieval integration (push) Successful in 14m18s
This commit is contained in:
1 parent
280292d72e
commit
756b8fe59e
2 files changed
+27
-1
No files matched your search
@@ -4,6 +4,7 @@ import io
|
||||
import json
|
||||
from contextlib import redirect_stdout
|
||||
from pathlib import Path
|
||||
import py_compile
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -85,6 +86,25 @@ class SemanticRetrievalTests(unittest.TestCase):
|
||||
self.assertFalse(target.exists())
|
||||
self.assertFalse(state_path.exists())
|
||||
|
||||
def test_update_accepts_python_cache_but_rejects_foreign_cache_content(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
home = Path(directory) / 'home'
|
||||
target = home / '.my-ai-configuration/semantic-retrieval'
|
||||
target.mkdir(parents=True)
|
||||
files = {}
|
||||
for name in MODULE.FILES:
|
||||
content = (ROOT / 'shared/retrieval' / name).read_bytes()
|
||||
(target / name).write_bytes(content)
|
||||
files[name] = hashlib.sha256(content).hexdigest()
|
||||
MODULE.save_state(target.parent / 'semantic-retrieval.json', {'version': 1, 'clients': ['codex'], 'files': files}, False)
|
||||
py_compile.compile(str(target / 'server.py'), doraise=True)
|
||||
cache = target / '__pycache__'
|
||||
with patch.object(MODULE, 'ensure_runtime', return_value=Path('python')), patch.object(MODULE, 'ensure_models'):
|
||||
MODULE.sync(ROOT, home, ['codex'], True, False, True)
|
||||
(cache / 'foreign.txt').write_text('keep')
|
||||
with self.assertRaisesRegex(ValueError, '__pycache__'):
|
||||
MODULE.sync(ROOT, home, ['codex'], True, False, True)
|
||||
|
||||
def test_negative_benchmark_keeps_active_runtime(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
home = Path(directory) / 'home'
|
||||
|
||||
Reference in new issue
Block a user