Exemple #1
0
 def test_update_existing_folders(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     helpers.add_folder(glossary, 'bucket', "Bucket", {
         'English': u"Bucket 0",
         'German': u"Eimer 0"
     })
     self._import_xml(glossary, 'dump1.xml')
     self._check_folder_translations(glossary)
 def test_update_existing_elements(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     bucket = helpers.add_folder(glossary, 'bucket', "Bucket")
     helpers.add_element(bucket, 'water', "Water",
                         {'English': u"Water 0", 'German': "Wasser 0"})
     self._import_xml(glossary, 'dump1.xml')
     self._check_element_translations(glossary)
 def test_add_entry(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     bucket.manage_addGlossaryElement('2', "Water")
     water = bucket['2']
     self.assertEqual(search(glossary, path=ofs_path(water)), [water])
     self.assertEqual(search(glossary, English="Water"), [water])
Exemple #4
0
 def test_add_entry(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     bucket.manage_addGlossaryElement('2', "Water")
     water = bucket['2']
     self.assertEqual(search(glossary, path=ofs_path(water)), [water])
     self.assertEqual(search(glossary, English="Water"), [water])
Exemple #5
0
 def _export_for_unicode_test(self):
     glossary = helpers.make_glossary(self.portal, 'server_glossary')
     helpers.add_language(glossary, 'ru', "Russian")
     glass = helpers.add_folder(glossary, '1', "Glass",
                                {'Russian': u"Стекло"})
     vodka = helpers.add_element(glass, '2', "Vodka", {'Russian': u"Водка"})
     ice = helpers.add_element(glass, '3', "Ice", {'Russian': u"Лёд"})
     return glossary.dump_export()
Exemple #6
0
 def _make_server_glossary(self):
     glossary = helpers.make_glossary(self.portal, 'server_glossary')
     helpers.add_language(glossary, 'de', "German")
     bucket = helpers.add_folder(glossary, '1', "Bucket",
                                 {'German': "Eimer"})
     water = helpers.add_element(bucket, '2', "Water", {'German': "Wasser"})
     ice = helpers.add_element(bucket, '3', "Ice", {'German': "Eis"})
     return glossary
 def _export_for_unicode_test(self):
     glossary = helpers.make_glossary(self.portal, 'server_glossary')
     helpers.add_language(glossary, 'ru', "Russian")
     glass = helpers.add_folder(glossary, '1', "Glass",
                                {'Russian': u"Стекло"})
     vodka = helpers.add_element(glass, '2', "Vodka", {'Russian': u"Водка"})
     ice = helpers.add_element(glass, '3', "Ice", {'Russian': u"Лёд"})
     return glossary.dump_export()
 def _make_server_glossary(self):
     glossary = helpers.make_glossary(self.portal, 'server_glossary')
     helpers.add_language(glossary, 'de', "German")
     bucket = helpers.add_folder(glossary, '1', "Bucket",
                                 {'German': "Eimer"})
     water = helpers.add_element(bucket, '2', "Water", {'German': "Wasser"})
     ice = helpers.add_element(bucket, '3', "Ice", {'German': "Eis"})
     return glossary
Exemple #9
0
 def test_update_existing_elements(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     bucket = helpers.add_folder(glossary, 'bucket', "Bucket")
     helpers.add_element(bucket, 'water', "Water", {
         'English': u"Water 0",
         'German': "Wasser 0"
     })
     self._import_xml(glossary, 'dump1.xml')
     self._check_element_translations(glossary)
Exemple #10
0
    def test_edit_folder(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket")

        bucket.set_translations_list('German', "Eimer")
        self.assertEqual(search(glossary, German="Eimer"), [bucket])

        bucket.set_translations_list('English', "Bucket 0")
        self.assertEqual(search(glossary, English="Bucket 0"), [bucket])
    def test_term_not_in_zip(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket",
                                    {'German': "Eimer"})
        water = helpers.add_element(bucket, '5', "Fire", {'German': "Feuer"})

        self._perform_test_import(glossary)

        self.assertEqual(set(bucket.objectIds()), set(['2', '3']))
    def test_edit_folder(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket")

        bucket.set_translations_list('German', "Eimer")
        self.assertEqual(search(glossary, German="Eimer"), [bucket])

        bucket.set_translations_list('English', "Bucket 0")
        self.assertEqual(search(glossary, English="Bucket 0"), [bucket])
Exemple #13
0
    def test_term_not_in_zip(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket",
                                    {'German': "Eimer"})
        water = helpers.add_element(bucket, '5', "Fire", {'German': "Feuer"})

        self._perform_test_import(glossary)

        self.assertEqual(set(bucket.objectIds()), set(['2', '3']))
Exemple #14
0
    def test_term_new_english_titles(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket 0")
        water = helpers.add_element(bucket, '2', "Water 0")
        ice = helpers.add_element(bucket, '3', "Ice 0")

        self._perform_test_import(glossary)

        self.assertEqual(bucket.English, "Bucket")
        self.assertEqual(water.English, "Water")
        self.assertEqual(ice.English, "Ice")
    def test_term_new_english_titles(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket 0")
        water = helpers.add_element(bucket, '2', "Water 0")
        ice = helpers.add_element(bucket, '3', "Ice 0")

        self._perform_test_import(glossary)

        self.assertEqual(bucket.English, "Bucket")
        self.assertEqual(water.English, "Water")
        self.assertEqual(ice.English, "Ice")
    def test_folder_not_in_zip(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bottle = helpers.add_folder(glossary, '2', "Bottle",
                                    {'German': "Flasche"})
        water = helpers.add_element(bottle, '5', "Fire", {'German': "Feuer"})

        self._perform_test_import(glossary)

        folder_ids = glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE])
        self.assertEqual(folder_ids, ['1'])
Exemple #17
0
    def test_new_language(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket 0")
        water = helpers.add_element(bucket, '2', "Water 0")
        ice = helpers.add_element(bucket, '3', "Ice 0")

        self._perform_test_import(glossary)

        self.assertEqual(bucket.German, "Eimer")
        self.assertEqual(water.German, "Wasser")
        self.assertEqual(ice.German, "Eis")
    def test_new_language(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket 0")
        water = helpers.add_element(bucket, '2', "Water 0")
        ice = helpers.add_element(bucket, '3', "Ice 0")

        self._perform_test_import(glossary)

        self.assertEqual(bucket.German, "Eimer")
        self.assertEqual(water.German, "Wasser")
        self.assertEqual(ice.German, "Eis")
    def test_edit_entry(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket")
        water = helpers.add_element(bucket, '2', "Water")

        water.set_translations_list('German', "Wasser")
        self.assertEqual(search(glossary, German="Wasser"), [water])

        water.set_translations_list('English', "Water 0")
        self.assertEqual(search(glossary, English="Water 0"), [water])
Exemple #20
0
    def test_edit_entry(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket")
        water = helpers.add_element(bucket, '2', "Water")

        water.set_translations_list('German', "Wasser")
        self.assertEqual(search(glossary, German="Wasser"), [water])

        water.set_translations_list('English', "Water 0")
        self.assertEqual(search(glossary, English="Water 0"), [water])
Exemple #21
0
    def test_folder_not_in_zip(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bottle = helpers.add_folder(glossary, '2', "Bottle",
                                    {'German': "Flasche"})
        water = helpers.add_element(bottle, '5', "Fire", {'German': "Feuer"})

        self._perform_test_import(glossary)

        folder_ids = glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE])
        self.assertEqual(folder_ids, ['1'])
    def test_empty_folders(self):
        src_glossary = helpers.make_glossary(self.portal, 'server_glossary')
        glass = helpers.add_folder(src_glossary, '1', "Bucket")
        dump_file = src_glossary.dump_export()

        glossary = helpers.make_glossary(self.portal)
        glossary.dump_import(StringIO(dump_file), remove_items=True)

        self.assertEqual(glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE]),
                         ['1'])
        self.assertEqual(glossary['1'].title, "Bucket")
        self.assertEqual(glossary['1'].English, "Bucket")
Exemple #23
0
    def test_empty_folders(self):
        src_glossary = helpers.make_glossary(self.portal, 'server_glossary')
        glass = helpers.add_folder(src_glossary, '1', "Bucket")
        dump_file = src_glossary.dump_export()

        glossary = helpers.make_glossary(self.portal)
        glossary.dump_import(StringIO(dump_file), remove_items=True)

        self.assertEqual(glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE]),
                         ['1'])
        self.assertEqual(glossary['1'].title, "Bucket")
        self.assertEqual(glossary['1'].English, "Bucket")
Exemple #24
0
    def test_export_folders(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', 'Bucket')
        water = helpers.add_element(bucket, '2', 'Water')

        xliff = lxml.etree.parse(StringIO(glossary.xliff_export()))
        body = xliff.xpath('/xliff/file/body')[0]

        self.assertEqual(len(body.xpath('./trans-unit')), 1)
        unit = body.xpath('./trans-unit')[0]
        self.assertEqual(unit.attrib['id'], "2")
        self.assertEqual(unit.xpath('./source')[0].text, "Water")
        self.assertEqual(unit.xpath('./context-group')[0].attrib['name'], "1")
    def test_export_folders(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', 'Bucket')
        water = helpers.add_element(bucket, '2', 'Water')

        xliff = lxml.etree.parse(StringIO(glossary.xliff_export()))
        body = xliff.xpath('/xliff/file/body')[0]

        self.assertEqual(len(body.xpath('./trans-unit')), 1)
        unit = body.xpath('./trans-unit')[0]
        self.assertEqual(unit.attrib['id'], "2")
        self.assertEqual(unit.xpath('./source')[0].text, "Water")
        self.assertEqual(unit.xpath('./context-group')[0].attrib['name'], "1")
    def test_term_new_translations(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket",
                                    {'German': "Eimer 0"})
        water = helpers.add_element(bucket, '2', "Water",
                                    {'German': "Wasser 0"})
        ice = helpers.add_element(bucket, '3', "Ice", {'German': "Eis 0"})

        self._perform_test_import(glossary)

        self.assertEqual(bucket.German, "Eimer")
        self.assertEqual(water.German, "Wasser")
        self.assertEqual(ice.German, "Eis")
    def test_export_unicode(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'ru', "Russian")
        glass = helpers.add_folder(glossary, '1', 'Glass',
                                   {'Russian': u"Стекло"})
        vodka = helpers.add_element(glass, '2', "Vodka", {'Russian': u"Водка"})

        xliff_src = glossary.xliff_export(language="Russian")
        xliff = lxml.etree.parse(StringIO(xliff_src))
        unit = xliff.xpath('/xliff/file/body/trans-unit')[0]

        self.assertEqual(unit.xpath('./source')[0].text, "Vodka")
        self.assertEqual(unit.xpath('./target')[0].text, u"Водка")
        self.assertEqual(unit.xpath('./context-group')[0].text, u"Стекло")
Exemple #28
0
    def test_term_new_translations(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', "Bucket",
                                    {'German': "Eimer 0"})
        water = helpers.add_element(bucket, '2', "Water",
                                    {'German': "Wasser 0"})
        ice = helpers.add_element(bucket, '3', "Ice", {'German': "Eis 0"})

        self._perform_test_import(glossary)

        self.assertEqual(bucket.German, "Eimer")
        self.assertEqual(water.German, "Wasser")
        self.assertEqual(ice.German, "Eis")
Exemple #29
0
    def test_export_unicode(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'ru', "Russian")
        glass = helpers.add_folder(glossary, '1', 'Glass',
                                   {'Russian': u"Стекло"})
        vodka = helpers.add_element(glass, '2', "Vodka", {'Russian': u"Водка"})

        xliff_src = glossary.xliff_export(language="Russian")
        xliff = lxml.etree.parse(StringIO(xliff_src))
        unit = xliff.xpath('/xliff/file/body/trans-unit')[0]

        self.assertEqual(unit.xpath('./source')[0].text, "Vodka")
        self.assertEqual(unit.xpath('./target')[0].text, u"Водка")
        self.assertEqual(unit.xpath('./context-group')[0].text, u"Стекло")
    def test_export_translated(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', 'Bucket',
                                    {'German': "Eimer"})
        water = helpers.add_element(bucket, '2', 'Water', {'German': "Wasser"})

        xliff_src = glossary.xliff_export(language="German")
        xliff = lxml.etree.parse(StringIO(xliff_src))
        body = xliff.xpath('/xliff/file/body')[0]
        unit = body.xpath('./trans-unit')[0]

        self.assertEqual(unit.xpath('./source')[0].text, "Water")
        self.assertEqual(unit.xpath('./target')[0].text, "Wasser")
        self.assertEqual(unit.xpath('./context-group')[0].text, "Eimer")
Exemple #31
0
    def test_export_translated(self):
        glossary = helpers.make_glossary(self.portal)
        helpers.add_language(glossary, 'de', "German")
        bucket = helpers.add_folder(glossary, '1', 'Bucket',
                                    {'German': "Eimer"})
        water = helpers.add_element(bucket, '2', 'Water', {'German': "Wasser"})

        xliff_src = glossary.xliff_export(language="German")
        xliff = lxml.etree.parse(StringIO(xliff_src))
        body = xliff.xpath('/xliff/file/body')[0]
        unit = body.xpath('./trans-unit')[0]

        self.assertEqual(unit.xpath('./source')[0].text, "Water")
        self.assertEqual(unit.xpath('./target')[0].text, "Wasser")
        self.assertEqual(unit.xpath('./context-group')[0].text, "Eimer")
Exemple #32
0
    def test_export_blank_folders(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket")

        xliff_src = glossary.xliff_export(language="English",
                                          empty_folders=True)
        xliff = lxml.etree.parse(StringIO(xliff_src))
        body = xliff.xpath('/xliff/file/body')[0]

        self.assertEqual(len(body.xpath('./trans-unit')), 1)
        unit = body.xpath('./trans-unit')[0]
        self.assertEqual(unit.attrib['id'], "1_dummy")
        self.assertEqual(unit.xpath('./source')[0].text, None)
        self.assertEqual(unit.xpath('./target')[0].text, None)
        context_group = unit.xpath('./context-group')[0]
        self.assertEqual(context_group.attrib['name'], "1")
        self.assertEqual(context_group.text, "Bucket")
    def test_export_blank_folders(self):
        glossary = helpers.make_glossary(self.portal)
        bucket = helpers.add_folder(glossary, '1', "Bucket")

        xliff_src = glossary.xliff_export(language="English",
                                          empty_folders=True)
        xliff = lxml.etree.parse(StringIO(xliff_src))
        body = xliff.xpath('/xliff/file/body')[0]

        self.assertEqual(len(body.xpath('./trans-unit')), 1)
        unit = body.xpath('./trans-unit')[0]
        self.assertEqual(unit.attrib['id'], "1_dummy")
        self.assertEqual(unit.xpath('./source')[0].text, None)
        self.assertEqual(unit.xpath('./target')[0].text, None)
        context_group = unit.xpath('./context-group')[0]
        self.assertEqual(context_group.attrib['name'], "1")
        self.assertEqual(context_group.text, "Bucket")
 def test_update_existing_folders(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     helpers.add_folder(glossary, 'bucket', "Bucket",
                        {'English': u"Bucket 0", 'German': u"Eimer 0"})
     self._import_xml(glossary, 'dump1.xml')
     self._check_folder_translations(glossary)
Exemple #35
0
 def test_remove_entry(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     water = helpers.add_element(bucket, '2', "Water")
     bucket.manage_delObjects(['2'])
     self.assertEqual(search(glossary, path=ofs_path(water)), [])
 def test_remove_entry(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     water = helpers.add_element(bucket, '2', "Water")
     bucket.manage_delObjects(['2'])
     self.assertEqual(search(glossary, path=ofs_path(water)), [])
 def test_remove_folder(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     glossary.manage_delObjects(['1'])
     self.assertEqual(search(glossary, path=ofs_path(bucket)), [])
Exemple #38
0
 def test_delete_missing_elements(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     bucket = helpers.add_folder(glossary, 'bucket', "Bucket")
     boat = helpers.add_element(bucket, 'boat', "Boat")
     self._import_xml(glossary, 'dump1.xml')
     self.assertEqual(bucket.objectIds(), ['water', 'ice'])
Exemple #39
0
 def test_remove_folder(self):
     glossary = helpers.make_glossary(self.portal)
     bucket = helpers.add_folder(glossary, '1', "Bucket")
     glossary.manage_delObjects(['1'])
     self.assertEqual(search(glossary, path=ofs_path(bucket)), [])
Exemple #40
0
 def test_delete_missing_folders(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     helpers.add_folder(glossary, 'tree', "Tree")
     self._import_xml(glossary, 'dump1.xml')
     folder_ids = glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE])
     self.assertEqual(folder_ids, ['bucket', 'glass'])
 def test_delete_missing_elements(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     bucket = helpers.add_folder(glossary, 'bucket', "Bucket")
     boat = helpers.add_element(bucket, 'boat', "Boat")
     self._import_xml(glossary, 'dump1.xml')
     self.assertEqual(bucket.objectIds(), ['water', 'ice'])
 def test_delete_missing_folders(self):
     glossary = helpers.make_glossary(self.portal, langs=['de'])
     helpers.add_folder(glossary, 'tree', "Tree")
     self._import_xml(glossary, 'dump1.xml')
     folder_ids = glossary.objectIds([NAAYAGLOSSARY_FOLDER_METATYPE])
     self.assertEqual(folder_ids, ['bucket', 'glass'])