connect new templater implementation
This commit is contained in:
parent
fde8c33de0
commit
cae77c2d05
4 changed files with 40 additions and 47 deletions
|
|
@ -4,61 +4,54 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
from stacosys.core.templater import (
|
||||
Templater,
|
||||
TEMPLATE_APPROVE_COMMENT,
|
||||
TEMPLATE_DROP_COMMENT,
|
||||
TEMPLATE_NEW_COMMENT,
|
||||
TEMPLATE_NOTIFY_MESSAGE,
|
||||
TEMPLATE_RSS_TITLE_MESSAGE,
|
||||
)
|
||||
from stacosys.core.templater import Templater, Template
|
||||
|
||||
|
||||
def get_template_content(lang, template_name, **kwargs):
|
||||
current_path = os.path.dirname(__file__)
|
||||
template_path = os.path.abspath(os.path.join(current_path, "../stacosys/templates"))
|
||||
templater = Templater(lang, template_path)
|
||||
template = templater.get_template(template_name)
|
||||
templater = Templater(template_path)
|
||||
template = templater.get_template(lang, template_name)
|
||||
assert template
|
||||
return template.render(kwargs)
|
||||
|
||||
|
||||
def test_approve_comment():
|
||||
content = get_template_content("fr", TEMPLATE_APPROVE_COMMENT, original="[texte]")
|
||||
content = get_template_content("fr", Template.APPROVE_COMMENT, original="[texte]")
|
||||
assert content.startswith("Bonjour,\n\nLe commentaire sera bientôt publié.")
|
||||
assert content.endswith("[texte]")
|
||||
content = get_template_content("en", TEMPLATE_APPROVE_COMMENT, original="[texte]")
|
||||
content = get_template_content("en", Template.APPROVE_COMMENT, original="[texte]")
|
||||
assert content.startswith("Hi,\n\nThe comment should be published soon.")
|
||||
assert content.endswith("[texte]")
|
||||
|
||||
|
||||
def test_drop_comment():
|
||||
content = get_template_content("fr", TEMPLATE_DROP_COMMENT, original="[texte]")
|
||||
content = get_template_content("fr", Template.DROP_COMMENT, original="[texte]")
|
||||
assert content.startswith("Bonjour,\n\nLe commentaire ne sera pas publié.")
|
||||
assert content.endswith("[texte]")
|
||||
content = get_template_content("en", TEMPLATE_DROP_COMMENT, original="[texte]")
|
||||
content = get_template_content("en", Template.DROP_COMMENT, original="[texte]")
|
||||
assert content.startswith("Hi,\n\nThe comment will not be published.")
|
||||
assert content.endswith("[texte]")
|
||||
|
||||
|
||||
def test_new_comment():
|
||||
content = get_template_content("fr", TEMPLATE_NEW_COMMENT, comment="[comment]")
|
||||
content = get_template_content("fr", Template.NEW_COMMENT, comment="[comment]")
|
||||
assert content.startswith("Bonjour,\n\nUn nouveau commentaire a été posté")
|
||||
assert content.endswith("[comment]\n\n--\nStacosys")
|
||||
content = get_template_content("en", TEMPLATE_NEW_COMMENT, comment="[comment]")
|
||||
content = get_template_content("en", Template.NEW_COMMENT, comment="[comment]")
|
||||
assert content.startswith("Hi,\n\nA new comment has been submitted")
|
||||
assert content.endswith("[comment]\n\n--\nStacosys")
|
||||
|
||||
|
||||
def test_notify_message():
|
||||
content = get_template_content("fr", TEMPLATE_NOTIFY_MESSAGE)
|
||||
content = get_template_content("fr", Template.NOTIFY_MESSAGE)
|
||||
assert content == "Nouveau commentaire"
|
||||
content = get_template_content("en", TEMPLATE_NOTIFY_MESSAGE)
|
||||
content = get_template_content("en", Template.NOTIFY_MESSAGE)
|
||||
assert content == "New comment"
|
||||
|
||||
|
||||
def test_rss_title():
|
||||
content = get_template_content("fr", TEMPLATE_RSS_TITLE_MESSAGE, site="[site]")
|
||||
content = get_template_content("fr", Template.RSS_TITLE_MESSAGE, site="[site]")
|
||||
assert content == "[site] : commentaires"
|
||||
content = get_template_content("en", TEMPLATE_RSS_TITLE_MESSAGE, site="[site]")
|
||||
content = get_template_content("en", Template.RSS_TITLE_MESSAGE, site="[site]")
|
||||
assert content == "[site] : comments"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue