Exemple #1
0
 def test_return_400_if_unsupported_country_is_given(self):
     self.request.session = {}
     self.request.method = 'POST'
     self.request.POST['country'] = 'HEAVEN'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 400)
     self.assertFalse(geo.COUNTRY_SESSION_KEY in self.request.session)
Exemple #2
0
 def test_redirect_if_next_url_is_given(self):
     self.request.method = 'POST'
     self.request.GET['next'] = 'example.com'
     self.request.POST['country'] = 'JP'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.url, 'example.com')
Exemple #3
0
 def test_set_session_if_available(self):
     self.request.session = {}
     self.request.method = 'POST'
     self.request.POST['country'] = 'JP'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(self.request.session[geo.COUNTRY_SESSION_KEY], 'JP')
Exemple #4
0
 def test_only_post_allowed(self):
     self.request.method = 'GET'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 405)
Exemple #5
0
 def test_set_cookie_if_session_is_unavailable(self):
     self.request.method = 'POST'
     self.request.POST['country'] = 'JP'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.cookies[geo.COUNTRY_COOKIE_NAME].value, 'JP')