API - use Babel to translate emails
This commit is contained in:
@@ -33,7 +33,11 @@ class TestEmailTemplateForPasswordChange:
|
||||
def test_it_gets_subject(
|
||||
self, app: Flask, lang: str, expected_subject: str
|
||||
) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
subject = email_template.get_content(
|
||||
'password_change', lang, 'subject.txt', {}
|
||||
@@ -51,7 +55,11 @@ class TestEmailTemplateForPasswordChange:
|
||||
def test_it_gets_text_body(
|
||||
self, app: Flask, lang: str, expected_text_body: str
|
||||
) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', lang, 'body.txt', self.EMAIL_DATA
|
||||
@@ -60,7 +68,11 @@ class TestEmailTemplateForPasswordChange:
|
||||
assert text_body == expected_text_body
|
||||
|
||||
def test_it_gets_en_html_body(self, app: Flask) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', 'en', 'body.html', self.EMAIL_DATA
|
||||
@@ -69,7 +81,11 @@ class TestEmailTemplateForPasswordChange:
|
||||
assert expected_en_html_body in text_body
|
||||
|
||||
def test_it_gets_fr_html_body(self, app: Flask) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', 'fr', 'body.html', self.EMAIL_DATA
|
||||
@@ -94,7 +110,11 @@ class TestEmailTemplateForPasswordChangeWithSecurityInfos:
|
||||
def test_it_gets_subject(
|
||||
self, app: Flask, lang: str, expected_subject: str
|
||||
) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
subject = email_template.get_content(
|
||||
'password_change', lang, 'subject.txt', {}
|
||||
@@ -112,7 +132,11 @@ class TestEmailTemplateForPasswordChangeWithSecurityInfos:
|
||||
def test_it_gets_text_body(
|
||||
self, app: Flask, lang: str, expected_text_body: str
|
||||
) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', lang, 'body.txt', self.EMAIL_DATA
|
||||
@@ -121,7 +145,11 @@ class TestEmailTemplateForPasswordChangeWithSecurityInfos:
|
||||
assert text_body == expected_text_body
|
||||
|
||||
def test_it_gets_en_html_body(self, app: Flask) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', 'en', 'body.html', self.EMAIL_DATA
|
||||
@@ -130,7 +158,11 @@ class TestEmailTemplateForPasswordChangeWithSecurityInfos:
|
||||
assert expected_en_html_body_without_security in text_body
|
||||
|
||||
def test_it_gets_fr_html_body(self, app: Flask) -> None:
|
||||
email_template = EmailTemplate(app.config['TEMPLATES_FOLDER'])
|
||||
email_template = EmailTemplate(
|
||||
app.config['TEMPLATES_FOLDER'],
|
||||
app.config['TRANSLATIONS_FOLDER'],
|
||||
app.config['LANGUAGES'],
|
||||
)
|
||||
|
||||
text_body = email_template.get_content(
|
||||
'password_change', 'fr', 'body.html', self.EMAIL_DATA
|
||||
|
||||
Reference in New Issue
Block a user