generated from coulomb/repo-seed
Implement REUSE-WP-0013 registry establish, update, and stats
Some checks failed
ci / validate-registry (push) Has been cancelled
Some checks failed
ci / validate-registry (push) Has been cancelled
Add stats, establish (scaffold, publish-check, discover), and update CLI commands with optional llm-connect bridge, validate --root for sibling repos, pytest coverage, and documentation for sibling registry onboarding.
This commit is contained in:
53
tests/test_llm_bridge.py
Normal file
53
tests/test_llm_bridge.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from reuse_surface.llm_bridge import (
|
||||
extract_json_object,
|
||||
llm_connect_url,
|
||||
request_registry_draft,
|
||||
)
|
||||
|
||||
|
||||
def test_extract_json_object_from_fenced_block():
|
||||
data = extract_json_object('```json\n{"capabilities": []}\n```')
|
||||
assert data == {"capabilities": []}
|
||||
|
||||
|
||||
def test_llm_connect_url_missing_raises():
|
||||
with pytest.raises(ValueError, match="LLM_CONNECT_URL"):
|
||||
llm_connect_url(None)
|
||||
|
||||
|
||||
def test_request_registry_draft_mock_http():
|
||||
payload = {
|
||||
"content": json.dumps(
|
||||
{
|
||||
"capabilities": [
|
||||
{
|
||||
"id": "capability.demo.sample",
|
||||
"name": "Sample",
|
||||
"summary": "Demo capability",
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
class FakeResponse:
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
return False
|
||||
|
||||
def read(self):
|
||||
return json.dumps(payload).encode("utf-8")
|
||||
|
||||
with patch.dict("os.environ", {"LLM_CONNECT_URL": "http://llm.test"}):
|
||||
with patch("urllib.request.urlopen", return_value=FakeResponse()):
|
||||
draft = request_registry_draft("test prompt")
|
||||
assert draft["capabilities"][0]["id"] == "capability.demo.sample"
|
||||
Reference in New Issue
Block a user