def test_translate_terms(self):

        sample_index_data = {
            'download_url': u'moo',
            'notes': u'an interesting note',
            'tags': [u'moon', 'boon'],
            'title': u'david',
        }

        result = mulilingual_plugin.MultilingualDataset().before_index(
            sample_index_data)

        assert result == {
            'text_pl': '',
            'text_de': '',
            'text_ro': '',
            'title': u'david',
            'notes': u'an interesting note',
            'tags': [u'moon', 'boon'],
            'title_en': u'david',
            'download_url': u'moo',
            'text_it': u'italian boon',
            'text_es': '',
            'text_en': u'an interesting note moon boon moo',
            'text_nl': '',
            'title_it': u'italian david',
            'text_pt': '',
            'title_fr': u'french david',
            'text_fr': u'french note french boon french_moo french moon'
        }, result
Esempio n. 2
0
    def test_translate_terms(self):

        sample_index_data = {
            'download_url': u'moo',
            'notes': u'an interesting note',
            'tags': [u'moon', 'boon'],
            'title': u'david',
        }

        result = mulilingual_plugin.MultilingualDataset().before_index(
            sample_index_data)
        assert result == {
            'text_sr@latin': '',
            'text_fi': '',
            'text_de': '',
            'text_pt_BR': '',
            u'title_fr': u'french david',
            'text_fr': u'french note french boon french_moo french moon',
            'text_ja': '',
            'text_sr': '',
            'title': u'david',
            'text_ca': '',
            'download_url': u'moo',
            'text_hu': '',
            'text_sa': '',
            'text_cs_CZ': '',
            'text_nl': '',
            'text_no': '',
            'text_ko_KR': '',
            'text_sk': '',
            'text_bg': '',
            'text_sv': '',
            'tags': [u'moon', 'boon'],
            'text_el': '',
            'title_en': u'david',
            'text_en': u'an interesting note moon boon moo',
            'text_es': '',
            'text_sl': '',
            'text_pl': '',
            'notes': u'an interesting note',
            'text_lv': '',
            'text_it': u'italian boon',
            u'title_it': u'italian david',
            'text_ru': ''
        }, result
Esempio n. 3
0
    def test_translate_terms(self):
        data_dicts = [
            {
                "term": "moo",
                "term_translation": "french_moo",
                "lang_code": "fr",
            },
            {
                "term": "moo",
                "term_translation": "this should not be rendered",
                "lang_code": "fsdas",
            },
            {
                "term": "an interesting note",
                "term_translation": "french note",
                "lang_code": "fr",
            },
            {
                "term": "moon",
                "term_translation": "french moon",
                "lang_code": "fr",
            },
            {
                "term": "boon",
                "term_translation": "french boon",
                "lang_code": "fr",
            },
            {
                "term": "boon",
                "term_translation": "italian boon",
                "lang_code": "it",
            },
            {
                "term": "david",
                "term_translation": "french david",
                "lang_code": "fr",
            },
            {
                "term": "david",
                "term_translation": "italian david",
                "lang_code": "it",
            },
        ]

        for data_dict in data_dicts:
            call_action("term_translation_update", **data_dict)

        sample_index_data = {
            "download_url": u"moo",
            "notes": u"an interesting note",
            "tags": [u"moon", "boon"],
            "title": u"david",
        }

        result = mulilingual_plugin.MultilingualDataset().before_dataset_index(
            sample_index_data)
        assert result == {
            "text_sr@latin": "",
            "text_fi": "",
            "text_de": "",
            "text_pt_BR": "",
            u"title_fr": u"french david",
            "text_fr": u"french_moo french note french moon french boon",
            "text_ja": "",
            "text_sr": "",
            "title": u"david",
            "text_ca": "",
            "download_url": u"moo",
            "text_hu": "",
            "text_sa": "",
            "text_cs_CZ": "",
            "text_nl": "",
            "text_no": "",
            "text_ko_KR": "",
            "text_sk": "",
            "text_bg": "",
            "text_sv": "",
            "tags": [u"moon", "boon"],
            "text_el": "",
            "title_en": u"david",
            "text_en": u"moo an interesting note moon boon",
            "text_es": "",
            "text_sl": "",
            "text_pl": "",
            "notes": u"an interesting note",
            "text_lv": "",
            "text_it": u"italian boon",
            u"title_it": u"italian david",
            "text_ru": "",
        }, result
Esempio n. 4
0
    def test_translate_terms(self):
        data_dicts = [{
            'term': 'moo',
            'term_translation': 'french_moo',
            'lang_code': 'fr'
        }, {
            'term': 'moo',
            'term_translation': 'this should not be rendered',
            'lang_code': 'fsdas'
        }, {
            'term': 'an interesting note',
            'term_translation': 'french note',
            'lang_code': 'fr'
        }, {
            'term': 'moon',
            'term_translation': 'french moon',
            'lang_code': 'fr'
        }, {
            'term': 'boon',
            'term_translation': 'french boon',
            'lang_code': 'fr'
        }, {
            'term': 'boon',
            'term_translation': 'italian boon',
            'lang_code': 'it'
        }, {
            'term': 'david',
            'term_translation': 'french david',
            'lang_code': 'fr'
        }, {
            'term': 'david',
            'term_translation': 'italian david',
            'lang_code': 'it'
        }]

        context = {
            'model': ckan.model,
            'session': ckan.model.Session,
            'user': '******',
            'ignore_auth': True,
        }
        for data_dict in data_dicts:
            ckan.logic.action.update.term_translation_update(
                context, data_dict)

        sample_index_data = {
            'download_url': u'moo',
            'notes': u'an interesting note',
            'tags': [u'moon', 'boon'],
            'title': u'david',
        }

        result = mulilingual_plugin.MultilingualDataset().before_index(
            sample_index_data)
        assert result == {
            'text_sr@latin': '',
            'text_fi': '',
            'text_de': '',
            'text_pt_BR': '',
            u'title_fr': u'french david',
            'text_fr': u'french note french moon french boon french_moo',
            'text_ja': '',
            'text_sr': '',
            'title': u'david',
            'text_ca': '',
            'download_url': u'moo',
            'text_hu': '',
            'text_sa': '',
            'text_cs_CZ': '',
            'text_nl': '',
            'text_no': '',
            'text_ko_KR': '',
            'text_sk': '',
            'text_bg': '',
            'text_sv': '',
            'tags': [u'moon', 'boon'],
            'text_el': '',
            'title_en': u'david',
            'text_en': u'an interesting note moon boon moo',
            'text_es': '',
            'text_sl': '',
            'text_pl': '',
            'notes': u'an interesting note',
            'text_lv': '',
            'text_it': u'italian boon',
            u'title_it': u'italian david',
            'text_ru': ''
        }, result