Migrate all repos into monorepo context folders
Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
"""Tests for prompt builder."""
|
||||
|
||||
import pytest
|
||||
|
||||
from ai_orchestrator.models import Issue
|
||||
from ai_orchestrator.prompt import (
|
||||
DEFAULT_PROMPT,
|
||||
TemplateParseError,
|
||||
TemplateRenderError,
|
||||
render_prompt,
|
||||
)
|
||||
|
||||
|
||||
def make_issue(**kwargs) -> Issue:
|
||||
"""Create a test issue with defaults."""
|
||||
defaults = {
|
||||
"id": "issue-1",
|
||||
"identifier": "ABC-123",
|
||||
"title": "Fix the bug",
|
||||
"description": "Something is broken",
|
||||
"state": "In Progress",
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return Issue(**defaults)
|
||||
|
||||
|
||||
class TestRenderPrompt:
|
||||
"""Tests for prompt rendering."""
|
||||
|
||||
def test_basic_rendering(self):
|
||||
template = "Work on {{ issue.identifier }}: {{ issue.title }}"
|
||||
issue = make_issue()
|
||||
result = render_prompt(template, issue)
|
||||
assert result == "Work on ABC-123: Fix the bug"
|
||||
|
||||
def test_attempt_variable(self):
|
||||
template = "{% if attempt %}Retry #{{ attempt }}{% endif %}"
|
||||
issue = make_issue()
|
||||
result = render_prompt(template, issue, attempt=3)
|
||||
assert result == "Retry #3"
|
||||
|
||||
def test_attempt_none_on_first_run(self):
|
||||
template = "{% if attempt %}retry{% else %}first{% endif %}"
|
||||
issue = make_issue()
|
||||
result = render_prompt(template, issue, attempt=None)
|
||||
assert result == "first"
|
||||
|
||||
def test_empty_template_returns_default(self):
|
||||
issue = make_issue()
|
||||
result = render_prompt("", issue)
|
||||
assert result == DEFAULT_PROMPT
|
||||
|
||||
def test_unknown_variable_fails(self):
|
||||
template = "{{ unknown_var }}"
|
||||
issue = make_issue()
|
||||
with pytest.raises(TemplateRenderError):
|
||||
render_prompt(template, issue)
|
||||
|
||||
def test_issue_labels_iterable(self):
|
||||
template = "{% for label in issue.labels %}{{ label }} {% endfor %}"
|
||||
issue = make_issue(labels=["bug", "urgent"])
|
||||
result = render_prompt(template, issue)
|
||||
assert "bug" in result
|
||||
assert "urgent" in result
|
||||
|
||||
def test_issue_description_none(self):
|
||||
template = "{{ issue.description or 'No description' }}"
|
||||
issue = make_issue(description=None)
|
||||
result = render_prompt(template, issue)
|
||||
assert result == "No description"
|
||||
|
||||
def test_syntax_error_raises(self):
|
||||
template = "{% if unclosed"
|
||||
issue = make_issue()
|
||||
with pytest.raises(TemplateParseError):
|
||||
render_prompt(template, issue)
|
||||
Reference in New Issue
Block a user