test_momentjs.py 1.2 KB

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