test_momentjs.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from django.conf import settings
  2. from django.test import TestCase
  3. from misago.core.momentjs import get_locale_path, list_available_locales
  4. class MomentJSTests(TestCase):
  5. def test_list_available_locales(self):
  6. """list_available_locales returns list of locales"""
  7. TEST_CASES = (
  8. 'af',
  9. 'ar-sa',
  10. 'de',
  11. 'et',
  12. 'pl',
  13. 'ru',
  14. 'pt-br',
  15. 'zh-tw'
  16. )
  17. locales = list_available_locales().keys()
  18. for language in TEST_CASES:
  19. self.assertIn(language, locales)
  20. def test_get_locale_path(self):
  21. """get_locale_path returns path to locale or null if it doesnt exist"""
  22. EXISTING_LOCALES = (
  23. 'af',
  24. 'ar-sa',
  25. 'ar-sasa',
  26. 'de',
  27. 'et',
  28. 'pl',
  29. 'pl-pl',
  30. 'ru',
  31. 'pt-br',
  32. 'zh-tw'
  33. )
  34. for language in EXISTING_LOCALES:
  35. self.assertIsNotNone(get_locale_path(language))
  36. NONEXISTING_LOCALES = (
  37. 'ga',
  38. 'en',
  39. 'en-us',
  40. 'martian',
  41. )
  42. for language in NONEXISTING_LOCALES:
  43. self.assertIsNone(get_locale_path(language))