# tests/test_template_meta.py
import pytest
from assets.runtime.create_feature import find_template_fields, render_request_from_template
def test_find_template_fields():
template_content = """
# Feature Request
**Title**:
**Intent**:
**Motivation / Problem**:
**Feature ID**:
**Meta**:
**Author**:
"""
fields = find_template_fields(template_content)
expected_fields = [
("Title", ""),
("Intent", ""),
("Motivation / Problem", ""),
("Author", "")
]
assert fields == expected_fields
def test_render_request_from_template():
template_content = """
# Feature Request:
**Intent**:
**Author**:
"""
fields = {
"Title": "My Awesome Feature",
"Intent": "This feature will do amazing things.",
"Author": "Test User"
}
fid = "FR_2023-10-27_my-awesome-feature"
created = "2023-10-27"
rendered_content = render_request_from_template(template_content, fields, fid, created)
expected_content = """
# Feature Request: My Awesome Feature
**Intent**: This feature will do amazing things.
**Author**: Test User
**Feature ID**: FR_2023-10-27_my-awesome-feature
**Meta**: Created: 2023-10-27 • Author: Test User
"""
assert rendered_content.strip() == expected_content.strip()
def test_render_request_from_template_with_existing_meta():
template_content = """
# Feature Request:
**Intent**:
**Author**:
**Feature ID**: EXISTING_FID
**Meta**: Existing Meta Info
"""
fields = {
"Title": "Another Feature",
"Intent": "This is another feature.",
"Author": "Another User"
}
fid = "FR_2023-10-28_another-feature"
created = "2023-10-28"
rendered_content = render_request_from_template(template_content, fields, fid, created)
expected_content = """
# Feature Request: Another Feature
**Intent**: This is another feature.
**Author**: Another User
**Feature ID**: EXISTING_FID
**Meta**: Existing Meta Info
"""
assert rendered_content.strip() == expected_content.strip()