Exemplo n.º 1
0
 def testReadCookie(self):
     app = LangMiddleware(self.app, ["en", "fr"], with_cookie=True)
     app = TestApp(app)
     environ = {"HTTP_COOKIE": '''foo="bar"; lang="fr"'''}
     res = app.get("/", extra_environ=environ)
     assert res.headers.get("Content-Language") == "fr"
Exemplo n.º 2
0
 def testSetCookie(self):
     app = LangMiddleware(self.app2, ["en", "fr"], with_cookie=True)
     app = TestApp(app)
     res = app.get("/")
     assert res.headers.get("Set-Cookie") is not None
Exemplo n.º 3
0
 def testSetLangFromApp(self):
     app = LangMiddleware(self.app2, ["en", "fr"])
     app = TestApp(app)
     res = app.get("/")
     assert res.headers.get("Content-Language") == "fr"
Exemplo n.º 4
0
 def testDiscroveryWithRegionAltFormatting(self):
     app = LangMiddleware(self.app, ["en", "fr"])
     app = TestApp(app)
     environ = {"HTTP_ACCEPT_LANGUAGE": "de-CH,de;q=0.9,en;q=0.8"}
     res = app.get("/", extra_environ=environ)
     assert res.headers.get("Content-Language") == "en"
Exemplo n.º 5
0
 def testDiscovery(self):
     app = LangMiddleware(self.app, ["en", "fr"])
     app = TestApp(app)
     environ = {"HTTP_ACCEPT_LANGUAGE": "fr, en;q=0.8"}
     res = app.get("/", extra_environ=environ)
     assert res.headers.get("Content-Language") == "fr"
Exemplo n.º 6
0
 def testDefaultLanguage(self):
     app = LangMiddleware(self.app, ["fr"])
     app = TestApp(app)
     res = app.get("/")
     assert res.headers.get("Content-Language") == "fr"
     assert res.body == "fr"