def test_registration_with_lang_suffix(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example1', "Foo 1",
                       change_master_with_language_id=True)
     self.assertTrue('item_1-en' in portal.portal_vocabularies.example1.objectIds())
 def test_linguaplone_multiple_values(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example6', "Foo 6", null_values=['NULL',])
     self.assertEqual(portal.portal_vocabularies.example6['item_1-it'].getTranslationLanguages(),
                      ['en', 'it', 'es'])
     self.assertEqual(portal.portal_vocabularies.example6['item_1-it'].getTranslation('es').absolute_url(),
                      portal.portal_vocabularies.example6['item_1-es'].absolute_url())
 def test_basic_registration(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example1', "Foo 1",
                       description="Simple foo vocabulary")
     self.assertTrue('example1' in portal.portal_vocabularies.objectIds())
     self.assertEqual(portal.portal_vocabularies.example1.Title(), "Foo 1")
     self.assertEqual(portal.portal_vocabularies.example1.item_1.Title(), "Item one")
     self.assertEqual(portal.portal_vocabularies.example1.item_1.Language(), "en")
 def test_linguaplone_not_translate_master(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example4', "Foo 4")
     self.assertEqual(portal.portal_vocabularies.example4['item_1-it'].Title(), "Elemento unò")
     self.assertEqual(portal.portal_vocabularies.example4['item_1-it'].getTranslation(), None)
     # still, other row with master defined are LinguaPlone linked
     self.assertEqual(portal.portal_vocabularies.example4['item_2-it'].getTranslation().absolute_url(),
                      portal.portal_vocabularies.example4.item_2.absolute_url())
 def test_basic_linguaplone_behavior(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example3', "Foo 3")
     self.assertEqual(portal.portal_vocabularies.example3.item_1.Title(), "Item one")
     self.assertEqual(portal.portal_vocabularies.example3.item_1.Language(), "en")
     self.assertEqual(portal.portal_vocabularies.example3['item_1-it'].Title(), "Elemento unò")
     self.assertEqual(portal.portal_vocabularies.example3['item_1-it'].Language(), "it")
     self.assertEqual(portal.portal_vocabularies.example3['item_1-it'].getTranslation().absolute_url(),
                      portal.portal_vocabularies.example3.item_1.absolute_url())
 def test_sort_control(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example2', "Foo 2")
     self.assertEqual(portal.portal_vocabularies.example2.objectIds(),
                      ['item_3', 'item_1', 'item_2'])
     self.assertEqual(portal.portal_vocabularies.example2.getVocabularyLines(),
                      [('item_1', 'Item one'), ('item_3', 'Item three'), ('item_2', 'Item two')])
     portal_vocabularies.manage_delObjects('example2')
     createVocabulary(portal_vocabularies, base_path, 'example2', "Foo 2",
                       sortMethod='getObjPositionInParent')
     self.assertEqual(portal.portal_vocabularies.example2.objectIds(),
                      ['item_3', 'item_1', 'item_2'])
     self.assertEqual(portal.portal_vocabularies.example2.getVocabularyLines(),
                      [('item_3', 'Item three'), ('item_1', 'Item one'), ('item_2', 'Item two')])
 def test_linguaplone_null_values(self):
     portal = self.layer['portal']
     portal_vocabularies = portal.portal_vocabularies
     base_path = os.path.join(os.path.dirname( __file__ ), 'csv')
     createVocabulary(portal_vocabularies, base_path, 'example5', "Foo 5", null_values=['NULL',])
     self.assertEqual(portal.portal_vocabularies.example5.objectIds(), ['item_1'])