Skip to content

Commit

Permalink
Add view logic and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maureenlholland committed Jan 21, 2025
1 parent 38872ff commit 663de13
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
51 changes: 51 additions & 0 deletions bedrock/firefox/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 5 additions & 2 deletions bedrock/firefox/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 663de13

Please sign in to comment.