Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoChevalier committed Mar 24, 2020
1 parent 5a5e86b commit 4125fef
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion network-api/networkapi/buyersguide/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,27 @@ def test_homepage(self):

def test_localised_homepage(self):
"""
Test that the homepage redirects when missing a locale code.
Test that the homepage redirects properly under different locale configurations.
"""
response = self.client.get('/privacynotincluded/')
self.assertEqual(response.status_code, 302, 'simple locale gets redirected')

response = self.client.get('/privacynotincluded', follow=True, HTTP_ACCEPT_LANGUAGE='fr')
self.assertEqual(
response.redirect_chain[0][0],
'/fr/privacynotincluded/',
'redirects according to HTTP_ACCEPT_LANGUAGE'
)
self.assertEqual(response.status_code, 200)

response = self.client.get('/privacynotincluded', follow=True, HTTP_ACCEPT_LANGUAGE='foo')
self.assertEqual(response.redirect_chain[0][0], '/en/privacynotincluded/', 'redirects to /en/ by default')
self.assertEqual(response.status_code, 200)

response = self.client.get('/de/privacynotincluded', follow=True, HTTP_ACCEPT_LANGUAGE='it')
self.assertEqual(response.redirect_chain[0][0], '/de/privacynotincluded/', 'no redirect from hardcoded locale')
self.assertEqual(response.status_code, 200)

def test_product_view_404(self):
"""
Test that the product view raises an Http404 if the product name doesn't exist
Expand Down

0 comments on commit 4125fef

Please sign in to comment.