lib.itmens/catalog/common/tests.py
2024-11-30 13:24:42 -05:00

27 lines
789 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.test import TestCase
from common.models import (
LANGUAGE_CHOICES,
LOCALE_CHOICES,
SCRIPT_CHOICES,
SITE_DEFAULT_LANGUAGE,
SITE_PREFERRED_LANGUAGES,
SITE_PREFERRED_LOCALES,
detect_language,
)
class CommonTestCase(TestCase):
databases = "__all__"
def test_detect_lang(self):
lang = detect_language("The Witcher 3: Wild Hunt")
self.assertEqual(lang, "en")
lang = detect_language("巫师3狂猎")
self.assertEqual(lang, "zh-cn")
lang = detect_language("巫师3狂猎 The Witcher 3: Wild Hunt")
self.assertEqual(lang, "zh-cn")
def test_lang_list(self):
self.assertGreaterEqual(len(SITE_PREFERRED_LANGUAGES), 1)
self.assertGreaterEqual(len(SITE_PREFERRED_LOCALES), 1)