This commit is contained in:
@@ -100,6 +100,7 @@ def _make_chromadb_mock() -> MagicMock:
|
||||
client.get_or_create_collection.return_value = collection
|
||||
chroma_mod = MagicMock()
|
||||
chroma_mod.PersistentClient.return_value = client
|
||||
chroma_mod.HttpClient.return_value = client
|
||||
return chroma_mod
|
||||
|
||||
|
||||
@@ -251,3 +252,28 @@ def test_runbook_store_sync_single_missing_file_raises(tmp_path: Path) -> None:
|
||||
store = RunbookStore(tmp_path / "store")
|
||||
with pytest.raises(FileNotFoundError):
|
||||
store.sync_single(tmp_path / "missing.md", ai)
|
||||
|
||||
|
||||
def test_runbook_store_remote_url_uses_http_client() -> None:
|
||||
chroma_mock = _make_chromadb_mock()
|
||||
|
||||
with patch.dict("sys.modules", {"chromadb": chroma_mock}):
|
||||
store = RunbookStore("https://chroma.example.com:8443")
|
||||
assert store.count() == 0
|
||||
|
||||
chroma_mock.HttpClient.assert_called_once_with(host="chroma.example.com", port=8443, ssl=True)
|
||||
|
||||
|
||||
def test_runbook_store_remote_url_uses_http_client_with_basic_auth() -> None:
|
||||
chroma_mock = _make_chromadb_mock()
|
||||
|
||||
with patch.dict("sys.modules", {"chromadb": chroma_mock}):
|
||||
store = RunbookStore("https://chroma.example.com:8443", username="tai", password="secret")
|
||||
assert store.count() == 0
|
||||
|
||||
args = chroma_mock.HttpClient.call_args.kwargs
|
||||
assert args["host"] == "chroma.example.com"
|
||||
assert args["port"] == 8443
|
||||
assert args["ssl"] is True
|
||||
assert "headers" in args
|
||||
assert str(args["headers"].get("Authorization", "")).startswith("Basic ")
|
||||
|
||||
Reference in New Issue
Block a user