CascadingDev/tests/test_template_meta.py

82 lines
2.3 KiB
Python

# 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**: <title>
**Intent**: <one paragraph describing purpose>
**Motivation / Problem**: <why this is needed now>
**Feature ID**: <will be generated>
**Meta**: <will be generated>
**Author**: <name>
"""
fields = find_template_fields(template_content)
expected_fields = [
("Title", "<title>"),
("Intent", "<one paragraph describing purpose>"),
("Motivation / Problem", "<why this is needed now>"),
("Author", "<name>")
]
assert fields == expected_fields
def test_render_request_from_template():
template_content = """
# Feature Request: <title>
**Intent**: <one paragraph describing purpose>
**Author**: <name>
"""
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: <title>
**Intent**: <one paragraph describing purpose>
**Author**: <name>
**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()