test_momentjs.py 1012 B

12345678910111213141516171819202122232425262728
  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 = (('AF', 'af'), ('ar-SA', 'ar-sa'), ('de', 'de'), ('de-NO', 'de'),
  7. ('pl-pl', 'pl'),
  8. ('zz', None), )
  9. for dirty, clean in TEST_CASES:
  10. self.assertEqual(clean_language_name(dirty), clean)
  11. def test_get_locale_path(self):
  12. """get_locale_path returns path to locale or null if it doesnt exist"""
  13. EXISTING_LOCALES = (
  14. 'af', 'ar-sa', 'ar-sasa', 'de', 'et', 'pl', 'pl-pl', 'ru', 'pt-br', 'zh-tw'
  15. )
  16. for language in EXISTING_LOCALES:
  17. self.assertIsNotNone(get_locale_url(language))
  18. NONEXISTING_LOCALES = ('ga', 'en', 'en-us', 'martian', )
  19. for language in NONEXISTING_LOCALES:
  20. self.assertIsNone(get_locale_url(language))