generated from coulomb/repo-seed
first steps to better scanning of repos
This commit is contained in:
@@ -2,10 +2,12 @@ from repo_registry.content_indexing.extractor import ContentExtractor
|
||||
from repo_registry.core.models import ObservedFact
|
||||
|
||||
|
||||
def fact(id, kind, name, path="", line=None):
|
||||
def fact(id, kind, name, path="", line=None, source_role=""):
|
||||
metadata = {}
|
||||
if line is not None:
|
||||
metadata["line"] = line
|
||||
if source_role:
|
||||
metadata["source_role"] = source_role
|
||||
return ObservedFact(
|
||||
id=id,
|
||||
repository_id=1,
|
||||
@@ -82,3 +84,20 @@ def test_content_extractor_chunks_provider_related_config(tmp_path):
|
||||
assert len(chunks) == 1
|
||||
assert chunks[0].path == ".env.example"
|
||||
assert "OPENROUTER_API_KEY" in chunks[0].text
|
||||
|
||||
|
||||
def test_content_extractor_preserves_source_role_metadata(tmp_path):
|
||||
repo = tmp_path / "repo"
|
||||
repo.mkdir()
|
||||
(repo / "SCOPE.md").write_text("# SCOPE\n\nProvides OIDC.\n", encoding="utf-8")
|
||||
|
||||
chunks = ContentExtractor().extract(
|
||||
repo,
|
||||
[
|
||||
fact(1, "scope", "SCOPE", "SCOPE.md", source_role="scope_summary"),
|
||||
],
|
||||
)
|
||||
|
||||
assert len(chunks) == 1
|
||||
assert chunks[0].kind == "scope"
|
||||
assert chunks[0].metadata["source_role"] == "scope_summary"
|
||||
|
||||
Reference in New Issue
Block a user