Beispiel #1
0
    def test_get_locale_multirepo(self):
        lang1 = eg_models.Localisation({'locale': 'eng_GB'})
        lang2 = eg_models.Localisation({'locale': 'spa_ES'})
        self.ws1.save(lang1, 'Added english')
        self.ws1.save(lang2, 'Added spanish')
        self.ws2.save(lang1, 'Added english')
        self.ws2.save(lang2, 'Added spanish')

        self.create_categories(self.ws1, locale='eng_GB', count=2)
        self.create_categories(self.ws1, locale='spa_ES', count=2)
        self.create_categories(self.ws2, locale='eng_GB', count=2)
        self.create_categories(self.ws2, locale='spa_ES', count=2)

        res = api.get_languages([self.repo1, self.repo2])

        self.assertEquals(
            res, {
                'locales': [{
                    'locale': 'eng_GB',
                    'name': 'English (United Kingdom)'
                }, {
                    'locale': 'spa_ES',
                    'name': 'Spanish (Spain)'
                }],
                'warnings': []
            })
Beispiel #2
0
def get_repo_languages(request):
    names = request.query_params.getlist('repo')
    repos = api.get_repos_by_name(names)
    result = api.get_languages(repos)

    return Response({
        'locales': result['locales'],
        'warnings': result['warnings']
    })
Beispiel #3
0
    def test_get_locale_multirepo_strays(self):
        lang1 = eg_models.Localisation({'locale': 'eng_GB'})
        lang2 = eg_models.Localisation({'locale': 'spa_ES'})
        lang3 = eg_models.Localisation({'locale': 'spa_MX'})
        lang4 = eg_models.Localisation({'locale': 'spa_CU'})

        self.ws1.save(lang1, 'Added english')
        self.ws1.save(lang2, 'Added spanish es')
        self.ws1.save(lang3, 'Added spanish mx')

        self.ws2.save(lang2, 'Added spanish es')
        self.ws2.save(lang3, 'Added spanish mx')
        self.ws2.save(lang4, 'Added spanish cu')

        self.create_categories(self.ws1, locale='eng_GB', count=2)
        self.create_categories(self.ws1, locale='spa_ES', count=2)
        self.create_categories(self.ws1, locale='spa_MX', count=2)

        self.create_categories(self.ws2, locale='spa_ES', count=2)
        self.create_categories(self.ws2, locale='spa_MX', count=2)
        self.create_categories(self.ws2, locale='spa_CU', count=2)

        res = api.get_languages([self.repo1, self.repo2])

        self.assertEquals(
            res, {
                'locales': [{
                    'locale': 'eng_GB',
                    'name': 'English (United Kingdom)'
                }, {
                    'locale': 'spa_CU',
                    'name': 'Spanish (Cuba)'
                }, {
                    'locale': 'spa_ES',
                    'name': 'Spanish (Spain)'
                }, {
                    'locale': 'spa_MX',
                    'name': 'Spanish (Mexico)'
                }],
                'warnings': [{
                    'type': 'stray_locale',
                    'details': {
                        'repo': 'repo1',
                        'locale': 'eng_GB',
                        'name': 'English (United Kingdom)'
                    }
                }, {
                    'type': 'stray_locale',
                    'details': {
                        'repo': 'repo2',
                        'locale': 'spa_CU',
                        'name': 'Spanish (Cuba)'
                    }
                }]
            })
Beispiel #4
0
    def test_unknown_locale(self):
        lang1 = eg_models.Localisation({'locale': 'eng_GB'})
        lang2 = eg_models.Localisation({'locale': 'Zre_ZR'})

        self.ws1.save(lang1, 'Added english language')
        self.ws1.save(lang2, 'Added a language with unknown locale')

        self.create_categories(self.ws1, locale='eng_GB', count=2)
        self.create_categories(self.ws1, locale='Zre_ZR', count=2)

        res = api.get_languages([self.repo1])

        self.assertEquals(
            res, {
                'locales': [{
                    'locale': u'Zre_ZR',
                    'name': u'Zre_ZR'
                }, {
                    'locale': 'eng_GB',
                    'name': 'English (United Kingdom)'
                }],
                'warnings': []
            })