tests.py 1020 Bytes
Newer Older
1
from django.urls import reverse
2 3
from django.test import TestCase

4 5
from languages.models import Language

6

7 8 9 10
class LanguageTestCase(TestCase):
    fixtures = ['sample_data.json']

    def testLanguageReleaseXML(self):
11
        response = self.client.get(reverse('language_release_xml', args=['fr', 'gnome-3-8']))
12
        self.assertContains(response, """<stats language="fr" release="gnome-3-8">""")
13 14 15 16 17 18

    def test_language_from_ianacode(self):
        Language.objects.create(name='Belarussian', locale='be')
        Language.objects.create(name='French (Belgium)', locale='fr_BE')
        Language.objects.create(name='Chinese (Taiwan)', locale='zh_TW')

19 20 21 22 23 24 25
        func = Language.get_language_from_ianacode
        self.assertEqual(func('fr-ch').locale, 'fr')
        self.assertEqual(func('fr-be').locale, 'fr_BE')
        self.assertEqual(func('be').locale, 'be')
        self.assertEqual(func('be-latin-RU').locale, 'be')
        self.assertEqual(func('zh-tw').locale, 'zh_TW')
        self.assertEqual(func('xx'), None)