'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(u'/')
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: u'pt-br'}
    r.META = {}
    self.assertEqual(u'pt-br', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: u'pt'}
    r.META = {}
    self.assertEqual(u'pt', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: u'es'}
    r.META = {u'HTTP_ACCEPT_LANGUAGE': u'de'}
    self.assertEqual(u'es', g(r))
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: u'es-us'}
    r.META = {}
    self.assertEqual(g(r), u'es')
    r.COOKIES = {settings.LANGUAGE_COOKIE_NAME: u'zh-cn'}
    r.META = {u'HTTP_ACCEPT_LANGUAGE': u'de'}
    self.assertEqual(g(r), u'zh-cn')
