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 testMergeWithDifferentKeysFail(self): array1 = StringArray('key a', ['en']) array2 = StringArray('key b', ['fr']) try: array1.merge(array2) self.fail('This operation should fail') except MstException: pass
def testMergeWithSameLanguagesFail(self): array1 = StringArray('key', ['en', 'fr']) array2 = StringArray('key', ['en', 'de']) try: array1.merge(array2) self.fail('This operation should fail') except MstException: pass
def testMergeWithSameLanguagesFail(self): array1 = StringArray('key', ['en', 'fr'] ) array2 = StringArray('key', ['en', 'de'] ) try: array1.merge(array2) self.fail('This operation should fail') except MstException: pass
def testMergeWithDifferentKeysFail(self): array1 = StringArray('key a', ['en']) array2 = StringArray('key b', ['fr']) try: array1.merge(array2) self.fail('This operation should fail') except MstException: pass