From 663de13b0266f83246d1c598a5d87cdba80a7b56 Mon Sep 17 00:00:00 2001 From: maureenlholland Date: Tue, 21 Jan 2025 16:08:11 -0500 Subject: [PATCH] Add view logic and tests --- ...snew-fx135.html => whatsnew-fx135-eu.html} | 0 bedrock/firefox/tests/test_base.py | 51 +++++++++++++++++++ bedrock/firefox/views.py | 7 ++- 3 files changed, 56 insertions(+), 2 deletions(-) rename bedrock/firefox/templates/firefox/whatsnew/{whatsnew-fx135.html => whatsnew-fx135-eu.html} (100%) diff --git a/bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx135.html b/bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx135-eu.html similarity index 100% rename from bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx135.html rename to bedrock/firefox/templates/firefox/whatsnew/whatsnew-fx135-eu.html diff --git a/bedrock/firefox/tests/test_base.py b/bedrock/firefox/tests/test_base.py index 77160917ab0..0f5b1b771f9 100644 --- a/bedrock/firefox/tests/test_base.py +++ b/bedrock/firefox/tests/test_base.py @@ -1164,6 +1164,57 @@ def test_fx_134_0_0_es_es(self, render_mock): # end 134.0 whatsnew tests + # begin 135.0 whatsnew tests + + @override_settings(DEV=True) + def test_fx_135_0_0_fr(self, render_mock): + """Should use whatsnew-fx135-eu.html template for fr locale""" + req = self.rf.get("/firefox/whatsnew/") + req.locale = "fr" + self.view(req, version="135.0") + template = render_mock.call_args[0][1] + assert template == ["firefox/whatsnew/whatsnew-fx135-eu.html"] + + @override_settings(DEV=True) + def test_fx_135_0_0_de(self, render_mock): + """Should use whatsnew-fx135-eu.html template for de locale""" + req = self.rf.get("/firefox/whatsnew/") + req.locale = "de" + self.view(req, version="135.0") + template = render_mock.call_args[0][1] + assert template == ["firefox/whatsnew/whatsnew-fx135-eu.html"] + + @override_settings(DEV=True) + def test_fx_135_0_0_en_gb(self, render_mock): + """Should use whatsnew-fx135-eu.html template for en locale and country GB""" + req = self.rf.get("/firefox/whatsnew/") + req.locale = "en-US" + req.country = "GB" + self.view(req, version="135.0") + template = render_mock.call_args[0][1] + assert template == ["firefox/whatsnew/whatsnew-fx135-eu.html"] + + @override_settings(DEV=True) + def test_fx_135_0_0_non_en_gb(self, render_mock): + """Should use default WNP template for non-en locale and country GB""" + req = self.rf.get("/firefox/whatsnew/") + req.locale = "es-ES" + req.country = "GB" + self.view(req, version="135.0") + template = render_mock.call_args[0][1] + assert template == ["firefox/whatsnew/index.html"] + + @override_settings(DEV=True) + def test_fx_135_0_0_es_es(self, render_mock): + """Should use default WNP template for other locales""" + req = self.rf.get("/firefox/whatsnew/") + req.locale = "es-ES" + self.view(req, version="135.0") + template = render_mock.call_args[0][1] + assert template == ["firefox/whatsnew/index.html"] + + # end 135.0 whatsnew tests + @patch("bedrock.firefox.views.l10n_utils.render", return_value=HttpResponse()) class TestFirstRun(TestCase): diff --git a/bedrock/firefox/views.py b/bedrock/firefox/views.py index fb7f117a62e..e6812d004d9 100644 --- a/bedrock/firefox/views.py +++ b/bedrock/firefox/views.py @@ -505,7 +505,7 @@ class WhatsnewView(L10nTemplateView): "firefox/whatsnew/whatsnew-fx134-gb.html": ["firefox/whatsnew/whatsnew"], "firefox/whatsnew/whatsnew-fx134-de.html": ["firefox/whatsnew/whatsnew"], "firefox/whatsnew/whatsnew-fx134-fr.html": ["firefox/whatsnew/whatsnew"], - "firefox/whatsnew/whatsnew-fx135.html": ["firefox/whatsnew/whatsnew"], + "firefox/whatsnew/whatsnew-fx135-eu.html": ["firefox/whatsnew/whatsnew"], } # specific templates that should not be rendered in @@ -618,7 +618,10 @@ def get_template_names(self): else: template = "firefox/whatsnew/index.html" elif version.startswith("135."): - template = "firefox/whatsnew/whatsnew-fx135.html" + if locale in ["de", "fr"] or country == "GB" and locale.startswith("en-"): + template = "firefox/whatsnew/whatsnew-fx135-eu.html" + else: + template = "firefox/whatsnew/index.html" elif version.startswith("134."): if locale == "en-US": template = "firefox/whatsnew/whatsnew-fx134-us.html"