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 _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()
示例#4
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
示例#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()
示例#6
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)
示例#7
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")
示例#8
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_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")
示例#11
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")
    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")
示例#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']))
    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_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])
示例#16
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'])
示例#17
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])
    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'])
示例#19
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_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"Стекло")
示例#22
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")
示例#24
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")
 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)), [])
示例#26
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'])
 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'])
示例#28
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)), [])