'Now test that we parse language preferences stored in a cookie correctly.'

def test_parse_language_cookie(self):

    g = get_language_from_request
    r = self.rf.get('/')
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'pt-br'}
    r.META = {}
    self.assertEqual('pt-br', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'pt'}
    r.META = {}
    self.assertEqual('pt', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'es'}
    r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
    self.assertEqual('es', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'es-us'}
    r.META = {}
    self.assertEqual(g(r), 'es')
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: 'zh-hans'}
    r.META = {'HTTP_ACCEPT_LANGUAGE': 'de'}
    self.assertEqual(g(r), 'zh-hans')
