Ejemplo n.º 1
0
    def test_translation_set_language_to_session(self):
        factory = RequestFactory()
        request = factory.get(self.page_en.get_navigation_url())
        setattr(request, 'session', dict())
        translation_set_language(request, 'en')

        self.assertEqual(request.LANGUAGE_CODE, 'en')
        self.assertEqual(request.session[self.language_session_key], 'en')
Ejemplo n.º 2
0
    def test_translation_set_language_to_cookie(self):
        factory = RequestFactory()
        request = factory.get(self.page_en.get_navigation_url())
        response = translation_set_language(request, 'en')

        self.assertEqual(request.LANGUAGE_CODE, 'en')

        c_key = django_settings.LANGUAGE_COOKIE_NAME
        self.assertEqual(response.cookies[c_key].value, 'en')