def testMergeSuccess(self):
        arrays = []
        max_items = 10
        # create independend string arrays
        for lang in self.languages:
            array = StringArray('key', [lang])
            for index in range(0, max_items):
                array.add(lang, index, self.__build_test_string(lang, index))
            arrays.append(array)

        # check all items contain proper number of items for each language
        for array in arrays:
            for lang in array.languages:
                self.assertEqual(array.size(lang), max_items)

        # create empty string array
        merged = StringArray('key', [])

        # merge all arrays
        for array in arrays:
            merged.merge(array)

        # check if resulting array contains all languages from all merged items
        combined_languages = set()
        for array in arrays:
            combined_languages.update(array.languages)
        self.assertEqual(combined_languages, merged.languages)

        # check if merged item contain proper number of items for each language
        for lang in merged.languages:
            self.assertEqual(merged.size(lang), max_items)
 def testMergeSuccess(self):
     arrays = []
     max_items = 10
     # create independend string arrays
     for lang in self.languages:
         array = StringArray('key', [lang])
         for index in range(0,max_items):
             array.add(lang, index, self.__build_test_string(lang, index))
         arrays.append(array)
     
     # check all items contain proper number of items for each language
     for array in arrays:
         for lang in array.languages:
             self.assertEqual( array.size(lang), max_items )
     
     # create empty string array
     merged = StringArray('key', [])
     
     # merge all arrays
     for array in arrays:
         merged.merge(array)
     
     # check if resulting array contains all languages from all merged items
     combined_languages = set()
     for array in arrays:
         combined_languages.update( array.languages )
     self.assertEqual( combined_languages, merged.languages )
     
     # check if merged item contain proper number of items for each language        
     for lang in merged.languages:
         self.assertEqual( merged.size(lang), max_items ) 
 def testAddWithValidLanguageSucceed(self):
     string_array = StringArray('key', self.valid_languages)
     for index in range(0,3):
         for lang in self.valid_languages:
             text = build_test_string(lang)
             string_array.add(lang, index, text )
             self.assertEqual( text, string_array.get(lang, index) )   # get added item
             self.assertEqual( string_array.size(lang), index+1)       # check array size
 def testAddWithInvalidLanguageFails(self):
     string_array = StringArray('key', self.valid_languages)
     for index in range(0, 3):
         for lang in self.invalid_languages:
             text = build_test_string(lang)
             try:
                 string_array.add(lang, index, text)
                 self.fail('Operation should fail for language %s' % lang)
             except MstException:
                 pass
 def testAddWithInvalidLanguageFails(self):
     string_array = StringArray('key', self.valid_languages)
     for index in range(0,3):
         for lang in self.invalid_languages:
             text = build_test_string(lang)
             try:
                 string_array.add(lang, index, text )
                 self.fail('Operation should fail for language %s' % lang)
             except MstException:
                 pass
 def testAddWithValidLanguageSucceed(self):
     string_array = StringArray('key', self.valid_languages)
     for index in range(0, 3):
         for lang in self.valid_languages:
             text = build_test_string(lang)
             string_array.add(lang, index, text)
             self.assertEqual(text,
                              string_array.get(lang,
                                               index))  # get added item
             self.assertEqual(string_array.size(lang),
                              index + 1)  # check array size