Exemplo n.º 1
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')
Exemplo n.º 2
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)
Exemplo n.º 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')
Exemplo n.º 4
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)
Exemplo n.º 5
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")
Exemplo n.º 6
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")
Exemplo n.º 7
0
 def test_only_post_allowed(self):
     self.request.method = 'GET'
     response = set_country(self.request)
     self.assertEqual(response.status_code, 405)
Exemplo n.º 8
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')
Exemplo n.º 9
0
 def test_only_post_allowed(self):
     self.request.method = "GET"
     response = set_country(self.request)
     self.assertEqual(response.status_code, 405)
Exemplo n.º 10
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")