feat: make goosehints jinja templated (#43)

This commit is contained in:
Salman Mohammed
2024-09-04 11:44:34 -07:00
committed by GitHub
parent 7d5461d240
commit 72d927f84f
5 changed files with 86 additions and 20 deletions
+27 -2
View File
@@ -1,12 +1,23 @@
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import MagicMock, Mock
import pytest
from goose.toolkit.base import Requirements
from goose.toolkit.developer import Developer
from contextlib import contextmanager
import os
@contextmanager
def change_dir(new_dir):
"""Context manager to temporarily change the current working directory."""
original_dir = os.getcwd()
os.chdir(new_dir)
try:
yield
finally:
os.chdir(original_dir)
@pytest.fixture
@@ -30,6 +41,20 @@ def developer_toolkit():
return toolkit
def test_system_prompt_with_goosehints(temp_dir, developer_toolkit):
readme_file = temp_dir / "README.md"
readme_file.write_text("This is from the README.md file.")
hints_file = temp_dir / ".goosehints"
jinja_template_content = "Hints:\n\n{% include 'README.md' %}\nEnd."
hints_file.write_text(jinja_template_content)
with change_dir(temp_dir):
system_prompt = developer_toolkit.system()
expected_end = "Hints:\n\nThis is from the README.md file.\nEnd."
assert system_prompt.endswith(expected_end)
def test_update_plan(developer_toolkit):
tasks = [
{"description": "Task 1", "status": "planned"},