Merge branch 'dev' into oauth2

This commit is contained in:
Sam
2022-07-03 19:05:38 +02:00
176 changed files with 3782 additions and 2122 deletions

View File

@ -2,7 +2,8 @@
expected_en_text_body = """Hi test,
You have created an account on FitTrackee account. Use the link below to confirm your address email.
You have created an account on FitTrackee.
Use the link below to confirm your address email.
Verify your email: http://localhost/account-confirmation?token=xxx
@ -18,7 +19,7 @@ expected_fr_text_body = """Bonjour test,
Vous avez créé un compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour confirmer votre adresse email.
Vérifier l'adresse email : http://localhost/account-confirmation?token=xxx
Vérifier l'adresse email: http://localhost/account-confirmation?token=xxx
Pour vérification, cette demande a été reçue à partir d'un appareil sous Linux, utilisant le navigateur Firefox.
Si vous n'êtes pas à l'origine de la création de ce compte, vous pouvez ignorer cet e-mail.
@ -47,7 +48,7 @@ expected_en_html_body = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Hi test,</h1>
<p>You have created an account on FitTrackee account. Use the link below to confirm your address email.</p>
<p>You have created an account on FitTrackee. Use the button below to confirm your address email.</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -70,7 +71,7 @@ expected_en_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If youre having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">http://localhost/account-confirmation?token=xxx</p>
</td>
</tr>
@ -119,9 +120,7 @@ expected_fr_html_body = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Bonjour test,</h1>
<p>Vous avez créé un compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour confirmer votre adresse email.
</p>
<p>Vous avez créé un compte sur FitTrackee. Cliquez sur le bouton pour confirmer votre adresse email.</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -144,7 +143,7 @@ expected_fr_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur</p>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur.</p>
<p class="f-fallback sub">http://localhost/account-confirmation?token=xxx</p>
</td>
</tr>

View File

@ -42,7 +42,7 @@ expected_en_html_body = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Hi test,</h1>
<p>You recently requested to change your email address for your FitTrackee account to: </p>
<p>You recently requested to change your email address for your FitTrackee account to:</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -61,9 +61,8 @@ expected_en_html_body = """ <body>
If this email change wasn't initiated by you, please change your password immediately or contact your administrator if your account is locked.
</p>
<p>Thanks,
<br>
The FitTrackee Team
</p>
<br>The FitTrackee Team</p>
</div>
</td>
</tr>
@ -127,9 +126,8 @@ expected_fr_html_body = """ <body>
Si vous n'êtes pas à l'origine de cette modification, veuillez changer votre mot de passe immédiatement ou contacter l'administrateur si votre compte est bloqué.
</p>
<p>Merci,
<br>
L'équipe FitTrackee
</p>
<br>L'équipe FitTrackee</p>
</div>
</td>
</tr>

View File

@ -2,7 +2,8 @@
expected_en_text_body = """Hi test,
You recently requested to change your email address for your FitTrackee account. Use the link below to confirm this address.
You recently requested to change your email address for your FitTrackee account.
Use the link below to confirm this address.
Verify your email: http://localhost/email-update?token=xxx
@ -15,7 +16,8 @@ http://localhost"""
expected_en_text_body_without_security = """Hi test,
You recently requested to change your email address for your FitTrackee account. Use the link below to confirm this address.
You recently requested to change your email address for your FitTrackee account.
Use the link below to confirm this address.
Verify your email: http://localhost/email-update?token=xxx
@ -30,7 +32,7 @@ expected_fr_text_body = """Bonjour test,
Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour confirmer cette adresse email.
Vérifier l'adresse email : http://localhost/email-update?token=xxx
Vérifier l'adresse email: http://localhost/email-update?token=xxx
Pour vérification, cette demande a été reçue à partir d'un appareil sous Linux, utilisant le navigateur Firefox.
Si vous n'êtes pas à l'origine de cette modification, vous pouvez ignorer cet e-mail.
@ -44,7 +46,7 @@ expected_fr_text_body_without_security = """Bonjour test,
Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour confirmer cette adresse email.
Vérifier l'adresse email : http://localhost/email-update?token=xxx
Vérifier l'adresse email: http://localhost/email-update?token=xxx
Si vous n'êtes pas à l'origine de cette modification, vous pouvez ignorer cet e-mail.
@ -95,7 +97,7 @@ expected_en_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If youre having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">http://localhost/email-update?token=xxx</p>
</td>
</tr>
@ -166,7 +168,7 @@ expected_en_html_body_without_security = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If youre having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">http://localhost/email-update?token=xxx</p>
</td>
</tr>
@ -196,7 +198,7 @@ expected_en_html_body_without_security = """ <body>
</html>"""
expected_fr_html_body = """ <body>
<span class="preheader">Utiliser ce lien pour confirmer cette adresse email.</span>
<span class="preheader">Confirmer le changement d'adresse email.</span>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -215,9 +217,7 @@ expected_fr_html_body = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee.
Cliquez sur le bouton ci-dessous pour confirmer cette adresse email.
</p>
<p>Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee. Cliquez sur le bouton ci-dessous pour confirmer cette adresse email.</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -240,7 +240,7 @@ expected_fr_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur</p>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur.</p>
<p class="f-fallback sub">http://localhost/email-update?token=xxx</p>
</td>
</tr>
@ -270,7 +270,7 @@ expected_fr_html_body = """ <body>
</html>"""
expected_fr_html_body_without_security = """ <body>
<span class="preheader">Utiliser ce lien pour confirmer cette adresse email.</span>
<span class="preheader">Confirmer le changement d'adresse email.</span>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -289,9 +289,7 @@ expected_fr_html_body_without_security = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee.
Cliquez sur le bouton ci-dessous pour confirmer cette adresse email.
</p>
<p>Vous avez récemment demandé la modification de l'adresse email associée à votre compte sur FitTrackee. Cliquez sur le bouton ci-dessous pour confirmer cette adresse email.</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
<td align="center">
@ -313,7 +311,7 @@ expected_fr_html_body_without_security = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur</p>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur.</p>
<p class="f-fallback sub">http://localhost/email-update?token=xxx</p>
</td>
</tr>

View File

@ -68,9 +68,8 @@ expected_en_html_body = """ <body>
If this password change wasn't initiated by you, please change your password immediately or contact your administrator if your account is locked.
</p>
<p>Thanks,
<br>
The FitTrackee Team
</p>
<br>The FitTrackee Team</p>
</div>
</td>
</tr>
@ -120,9 +119,8 @@ expected_en_html_body_without_security = """ <body>
If this password change wasn't initiated by you, please change your password immediately or contact your administrator if your account is locked.
</p>
<p>Thanks,
<br>
The FitTrackee Team
</p>
<br>The FitTrackee Team</p>
</div>
</td>
</tr>
@ -173,9 +171,8 @@ expected_fr_html_body = """ <body>
Si vous n'êtes pas à l'origine de cette modification, veuillez changer votre mot de passe immédiatement ou contacter l'administrateur si votre compte est bloqué.
</p>
<p>Merci,
<br>
L'équipe FitTrackee
</p>
<br>L'équipe FitTrackee</p>
</div>
</td>
</tr>
@ -225,9 +222,8 @@ expected_fr_html_body_without_security = """ <body>
Si vous n'êtes pas à l'origine de cette modification, veuillez changer votre mot de passe immédiatement ou contacter l'administrateur si votre compte est bloqué.
</p>
<p>Merci,
<br>
L'équipe FitTrackee
</p>
<br>L'équipe FitTrackee</p>
</div>
</td>
</tr>

View File

@ -2,7 +2,8 @@
expected_en_text_body = """Hi test,
You recently requested to reset your password for your FitTrackee account. Use the link below to reset it. This password reset link is only valid for 3 seconds.
You recently requested to reset your password for your FitTrackee account. Use the link below to reset it.
This password reset link is only valid for 3 seconds.
Reset your password: http://localhost/password-reset?token=xxx
@ -15,7 +16,8 @@ http://localhost"""
expected_en_text_body_without_security = """Hi test,
You recently requested to reset your password for your FitTrackee account. Use the link below to reset it. This password reset link is only valid for 3 seconds.
You recently requested to reset your password for your FitTrackee account. Use the link below to reset it.
This password reset link is only valid for 3 seconds.
Reset your password: http://localhost/password-reset?token=xxx
@ -27,10 +29,10 @@ http://localhost"""
expected_fr_text_body = """Bonjour test,
Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour le réinitialiser. Ce lien n'est valide que pendant 3 secondes.
Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee. Cliquez sur le lien ci-dessous pour le réinitialiser.
Ce lien n'est valide que pendant 3 secondes.
Réinitialiser le mot de passe : http://localhost/password-reset?token=xxx
Réinitialiser le mot de passe: http://localhost/password-reset?token=xxx
Pour vérification, cette demande a été reçue à partir d'un appareil sous Linux, utilisant le navigateur Firefox.
Si vous n'avez pas demandé de réinitialisation, vous pouvez ignorer cet e-mail.
@ -41,10 +43,10 @@ http://localhost"""
expected_fr_text_body_without_security = """Bonjour test,
Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee.
Cliquez sur le lien ci-dessous pour le réinitialiser. Ce lien n'est valide que pendant 3 secondes.
Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee. Cliquez sur le lien ci-dessous pour le réinitialiser.
Ce lien n'est valide que pendant 3 secondes.
Réinitialiser le mot de passe : http://localhost/password-reset?token=xxx
Réinitialiser le mot de passe: http://localhost/password-reset?token=xxx
Si vous n'avez pas demandé de réinitialisation, vous pouvez ignorer cet e-mail.
@ -72,7 +74,7 @@ expected_en_html_body = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Hi test,</h1>
<p>You recently requested to reset your password for your account. Use the button below to reset it.
<p>You recently requested to reset your password for your FitTrackee account. Use the button below to reset it.
<strong>This password reset link is only valid for 3 seconds.</strong>
</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
@ -97,7 +99,7 @@ expected_en_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If youre having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">http://localhost/password-reset?token=xxx</p>
</td>
</tr>
@ -146,7 +148,7 @@ expected_en_html_body_without_security = """ <body>
<td class="content-cell">
<div class="f-fallback">
<h1>Hi test,</h1>
<p>You recently requested to reset your password for your account. Use the button below to reset it.
<p>You recently requested to reset your password for your FitTrackee account. Use the button below to reset it.
<strong>This password reset link is only valid for 3 seconds.</strong>
</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
@ -170,7 +172,7 @@ expected_en_html_body_without_security = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">If youre having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">If you're having trouble with the button above, copy and paste the URL below into your web browser.</p>
<p class="f-fallback sub">http://localhost/password-reset?token=xxx</p>
</td>
</tr>
@ -218,10 +220,9 @@ expected_fr_html_body = """ <body>
<tr>
<td class="content-cell">
<div class="f-fallback">
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee.
Cliquez sur le bouton ci-dessous pour le réinitialiser.
<strong>Cette réinitialisation n'est valide que pendant 3 secondes.</strong>
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee. Cliquez sur le bouton pour le réinitialiser.
<strong>Ce lien n'est valide que pendant 3 secondes.</strong>
</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
@ -245,7 +246,7 @@ expected_fr_html_body = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur</p>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur.</p>
<p class="f-fallback sub">http://localhost/password-reset?token=xxx</p>
</td>
</tr>
@ -294,10 +295,9 @@ expected_fr_html_body_without_security = """ <body>
<tr>
<td class="content-cell">
<div class="f-fallback">
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee.
Cliquez sur le bouton ci-dessous pour le réinitialiser.
<strong>Cette réinitialisation n'est valide que pendant 3 secondes.</strong>
<h1>Bonjour test,</h1>
<p>Vous avez récemment demandé la réinitialisation du mot de passe de votre compte sur FitTrackee. Cliquez sur le bouton pour le réinitialiser.
<strong>Ce lien n'est valide que pendant 3 secondes.</strong>
</p>
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">
<tr>
@ -320,7 +320,7 @@ expected_fr_html_body_without_security = """ <body>
<table class="body-sub" role="presentation">
<tr>
<td>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur</p>
<p class="f-fallback sub">Si vous avez des problèmes avec le bouton, vous pouvez copier et coller le lien suivant dans votre navigateur.</p>
<p class="f-fallback sub">http://localhost/password-reset?token=xxx</p>
</td>
</tr>

View File

@ -32,7 +32,11 @@ class TestEmailTemplateForAccountConfirmation:
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(
'account_confirmation', lang, 'subject.txt', {}
@ -50,7 +54,11 @@ class TestEmailTemplateForAccountConfirmation:
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(
'account_confirmation', lang, 'body.txt', self.EMAIL_DATA
@ -59,7 +67,11 @@ class TestEmailTemplateForAccountConfirmation:
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(
'account_confirmation', 'en', 'body.html', self.EMAIL_DATA
@ -68,7 +80,11 @@ class TestEmailTemplateForAccountConfirmation:
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(
'account_confirmation', 'fr', 'body.html', self.EMAIL_DATA

View File

@ -47,7 +47,11 @@ class TestEmailTemplateForEmailUpdateToCurrentEmail:
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(
'email_update_to_current_email', lang, 'subject.txt', {}
@ -65,7 +69,11 @@ class TestEmailTemplateForEmailUpdateToCurrentEmail:
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(
'email_update_to_current_email', lang, 'body.txt', self.EMAIL_DATA
@ -74,7 +82,11 @@ class TestEmailTemplateForEmailUpdateToCurrentEmail:
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(
'email_update_to_current_email', 'en', 'body.html', self.EMAIL_DATA
@ -83,7 +95,11 @@ class TestEmailTemplateForEmailUpdateToCurrentEmail:
assert expected_en_current_email_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(
'email_update_to_current_email', 'fr', 'body.html', self.EMAIL_DATA
@ -111,7 +127,11 @@ class TestEmailTemplateForEmailUpdateToNewEmail:
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(
'email_update_to_new_email', lang, 'subject.txt', {}
@ -129,7 +149,11 @@ class TestEmailTemplateForEmailUpdateToNewEmail:
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(
'email_update_to_new_email', lang, 'body.txt', self.EMAIL_DATA
@ -138,7 +162,11 @@ class TestEmailTemplateForEmailUpdateToNewEmail:
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(
'email_update_to_new_email', 'en', 'body.html', self.EMAIL_DATA
@ -147,7 +175,11 @@ class TestEmailTemplateForEmailUpdateToNewEmail:
assert expected_en_new_email_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(
'email_update_to_new_email', 'fr', 'body.html', self.EMAIL_DATA
@ -173,7 +205,11 @@ class TestEmailTemplateForEmailUpdateToNewEmailWithoutSecurityInfos:
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(
'email_update_to_new_email', lang, 'subject.txt', {}
@ -191,7 +227,11 @@ class TestEmailTemplateForEmailUpdateToNewEmailWithoutSecurityInfos:
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(
'email_update_to_new_email', lang, 'body.txt', self.EMAIL_DATA
@ -200,7 +240,11 @@ class TestEmailTemplateForEmailUpdateToNewEmailWithoutSecurityInfos:
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(
'email_update_to_new_email', 'en', 'body.html', self.EMAIL_DATA
@ -209,7 +253,11 @@ class TestEmailTemplateForEmailUpdateToNewEmailWithoutSecurityInfos:
assert expected_en_new_email_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(
'email_update_to_new_email', 'fr', 'body.html', self.EMAIL_DATA

View File

@ -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

View File

@ -26,7 +26,11 @@ class TestEmailTemplateForPasswordRequest:
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_reset_request', lang, 'subject.txt', {}
@ -41,7 +45,11 @@ class TestEmailTemplateForPasswordRequest:
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'],
)
email_data = {
'expiration_delay': '3 seconds' if lang == 'en' else '3 secondes',
'username': 'test',
@ -58,7 +66,11 @@ class TestEmailTemplateForPasswordRequest:
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'],
)
email_data = {
'expiration_delay': '3 seconds',
'username': 'test',
@ -75,7 +87,11 @@ class TestEmailTemplateForPasswordRequest:
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'],
)
email_data = {
'expiration_delay': '3 secondes',
'username': 'test',
@ -103,7 +119,11 @@ class TestEmailTemplateForPasswordRequestWithoutSecurityInfos:
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_reset_request', lang, 'subject.txt', {}
@ -121,7 +141,11 @@ class TestEmailTemplateForPasswordRequestWithoutSecurityInfos:
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'],
)
email_data = {
'expiration_delay': '3 seconds' if lang == 'en' else '3 secondes',
'username': 'test',
@ -136,7 +160,11 @@ class TestEmailTemplateForPasswordRequestWithoutSecurityInfos:
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'],
)
email_data = {
'expiration_delay': '3 seconds',
'username': 'test',
@ -151,7 +179,11 @@ class TestEmailTemplateForPasswordRequestWithoutSecurityInfos:
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'],
)
email_data = {
'expiration_delay': '3 secondes',
'username': 'test',

View File

@ -1,6 +1,7 @@
import json
from datetime import datetime, timedelta
from io import BytesIO
from typing import Optional
from unittest.mock import MagicMock, Mock, patch
import pytest
@ -233,7 +234,16 @@ class TestUserRegistration(ApiTestCaseMixin):
assert data['status'] == 'success'
assert 'auth_token' not in data
def test_it_creates_user_with_inactive_account(self, app: Flask) -> None:
@pytest.mark.parametrize(
'input_language,expected_language',
[('en', 'en'), ('fr', 'fr'), ('invalid', 'en'), (None, 'en')],
)
def test_it_creates_user_with_inactive_account(
self,
app: Flask,
input_language: Optional[str],
expected_language: str,
) -> None:
client = app.test_client()
username = self.random_string()
email = self.random_email()
@ -245,6 +255,7 @@ class TestUserRegistration(ApiTestCaseMixin):
username=username,
email=email,
password=self.random_string(),
language=input_language,
)
),
content_type='application/json',
@ -254,9 +265,18 @@ class TestUserRegistration(ApiTestCaseMixin):
assert new_user.email == email
assert new_user.password is not None
assert new_user.is_active is False
assert new_user.language == expected_language
def test_it_calls_account_confirmation_email_if_payload_is_valid(
self, app: Flask, account_confirmation_email_mock: Mock
@pytest.mark.parametrize(
'input_language,expected_language',
[('en', 'en'), ('fr', 'fr'), ('invalid', 'en'), (None, 'en')],
)
def test_it_calls_account_confirmation_email_when_payload_is_valid(
self,
app: Flask,
account_confirmation_email_mock: Mock,
input_language: Optional[str],
expected_language: str,
) -> None:
client = app.test_client()
email = self.random_email()
@ -271,6 +291,7 @@ class TestUserRegistration(ApiTestCaseMixin):
username=username,
email=email,
password='12345678',
language=input_language,
)
),
content_type='application/json',
@ -279,7 +300,7 @@ class TestUserRegistration(ApiTestCaseMixin):
account_confirmation_email_mock.send.assert_called_once_with(
{
'language': 'en',
'language': expected_language,
'email': email,
},
{
@ -1331,8 +1352,16 @@ class TestUserPreferencesUpdate(ApiTestCaseMixin):
self.assert_400(response)
@pytest.mark.parametrize(
'input_language,expected_language',
[('en', 'en'), ('fr', 'fr'), ('invalid', 'en'), (None, 'en')],
)
def test_it_updates_user_preferences(
self, app: Flask, user_1: User
self,
app: Flask,
user_1: User,
input_language: Optional[str],
expected_language: str,
) -> None:
client, auth_token = self.get_test_client_and_auth_token(
app, user_1.email
@ -1345,7 +1374,7 @@ class TestUserPreferencesUpdate(ApiTestCaseMixin):
dict(
timezone='America/New_York',
weekm=True,
language='fr',
language=input_language,
imperial_units=True,
)
),
@ -1356,6 +1385,7 @@ class TestUserPreferencesUpdate(ApiTestCaseMixin):
data = json.loads(response.data.decode())
assert data['status'] == 'success'
assert data['message'] == 'user preferences updated'
assert data['data']['language'] == expected_language
assert data['data'] == jsonify_dict(user_1.serialize(user_1))
@pytest.mark.parametrize(
@ -2487,6 +2517,7 @@ class TestResendAccountConfirmationEmail(ApiTestCaseMixin):
) -> None:
client = app.test_client()
expected_token = self.random_string()
inactive_user.language = 'fr'
with patch('secrets.token_urlsafe', return_value=expected_token):
client.post(
@ -2498,7 +2529,7 @@ class TestResendAccountConfirmationEmail(ApiTestCaseMixin):
account_confirmation_email_mock.send.assert_called_once_with(
{
'language': 'en',
'language': inactive_user.language,
'email': inactive_user.email,
},
{