test_momentjs.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from django.conf import settings
  2. from django.test import TestCase
  3. from misago.core.momentjs import clean_language_name, get_locale_url
  4. class MomentJSTests(TestCase):
  5. def test_clean_language_name(self):
  6. """clean_language_name returns valid name"""
  7. TEST_CASES = (
  8. ('AF', 'af'),
  9. ('ar-SA', 'ar-sa'),
  10. ('de', 'de'),
  11. ('de-NO', 'de'),
  12. ('pl-pl', 'pl'),
  13. ('zz', None),
  14. )
  15. for dirty, clean in TEST_CASES:
  16. self.assertEqual(clean_language_name(dirty), clean)
  17. def test_get_locale_path(self):
  18. """get_locale_path returns path to locale or null if it doesnt exist"""
  19. EXISTING_LOCALES = (
  20. 'af',
  21. 'ar-sa',
  22. 'ar-sasa',
  23. 'de',
  24. 'et',
  25. 'pl',
  26. 'pl-pl',
  27. 'ru',
  28. 'pt-br',
  29. 'zh-tw'
  30. )
  31. for language in EXISTING_LOCALES:
  32. self.assertIsNotNone(get_locale_url(language))
  33. NONEXISTING_LOCALES = (
  34. 'ga',
  35. 'en',
  36. 'en-us',
  37. 'martian',
  38. )
  39. for language in NONEXISTING_LOCALES:
  40. self.assertIsNone(get_locale_url(language))