diff options
Diffstat (limited to 'tests/functional-tests/16-collation.py')
-rwxr-xr-x | tests/functional-tests/16-collation.py | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/tests/functional-tests/16-collation.py b/tests/functional-tests/16-collation.py index 76e22f236..36a1fbbc7 100755 --- a/tests/functional-tests/16-collation.py +++ b/tests/functional-tests/16-collation.py @@ -29,31 +29,33 @@ import locale import unittest as ut from common.utils.storetest import CommonTrackerStoreTest as CommonTrackerStoreTest + class TrackerStoreCollationTests (CommonTrackerStoreTest): """ Insert few instances with a text field containing collation-problematic words. Ask for those instances order by the field and check the results. """ - def setUp (self): + + def setUp(self): """ Each test append to this list the used URIS, so they can be removed in the tearDown """ self.clean_up_instances = [] - def tearDown (self): + def tearDown(self): for uri in self.clean_up_instances: - self.tracker.update ("DELETE { <%s> a rdfs:Resource. }" % (uri)) + self.tracker.update("DELETE { <%s> a rdfs:Resource. }" % (uri)) self.clean_up_instances = [] - time.sleep (1) + time.sleep(1) - def __insert_text (self, text): - uri = "test://collation-01-%d" % (random.randint (1, 1000)) + def __insert_text(self, text): + uri = "test://collation-01-%d" % (random.randint(1, 1000)) # There is a remote chance to get a duplicate int while (uri in self.clean_up_instances): - uri = "test://collation-01-%d" % (random.randint (1, 1000)) - self.clean_up_instances.append (uri) - + uri = "test://collation-01-%d" % (random.randint(1, 1000)) + self.clean_up_instances.append(uri) + self.tracker.update (""" INSERT { <%s> a nie:InformationElement ; @@ -62,7 +64,7 @@ class TrackerStoreCollationTests (CommonTrackerStoreTest): } """ % (uri, text)) - def get_text_sorted_by_collation (self): + def get_text_sorted_by_collation(self): return self.tracker.query (""" SELECT ?title WHERE { ?u a nie:InformationElement ; @@ -71,57 +73,57 @@ class TrackerStoreCollationTests (CommonTrackerStoreTest): } ORDER BY ?title """) - def __collation_test (self, input_list, expected_list): + def __collation_test(self, input_list, expected_list): for i in input_list: - self.__insert_text (i) + self.__insert_text(i) - results = [r[0] for r in self.get_text_sorted_by_collation ()] - self.assertEqual (len (results), len (expected_list)) + results = [r[0] for r in self.get_text_sorted_by_collation()] + self.assertEqual(len(results), len(expected_list)) - for r in range (0, len (results)): - self.assertEqual (results[r], expected_list [r], - """Error: + for r in range(0, len(results)): + self.assertEqual(results[r], expected_list[r], + """Error: Expected : *** %s Result : *** %s Using locale (%s, %s) """ % (expected_list, results, - locale.getdefaultlocale ()[0], - locale.getdefaultlocale ()[1])) + locale.getdefaultlocale()[0], + locale.getdefaultlocale()[1])) - def test_collation_01 (self): + def test_collation_01(self): """ Behaves as case-insensitive """ input_dt = ["abb", "bb", "Abc", "Ba"] expected = ["abb", "Abc", "Ba", "bb"] - self.__collation_test (input_dt, expected) + self.__collation_test(input_dt, expected) - def test_collation_02 (self): + def test_collation_02(self): """ In conflict, Capital letters go *after* small letters """ input_dt = ["Bb", "bb", "aa", "Aa"] expected = ["aa", "Aa", "bb", "Bb"] - self.__collation_test (input_dt, expected) + self.__collation_test(input_dt, expected) - def test_collation_03 (self): + def test_collation_03(self): """ Example from the unicode spec http://www.unicode.org/reports/tr10/#Main_Algorithm """ input_dt = ["Cab", "cab", "dab", "cáb"] expected = ["cab", "Cab", "cáb", "dab"] - self.__collation_test (input_dt, expected) + self.__collation_test(input_dt, expected) - def test_collation_04 (self): + def test_collation_04(self): """ Spanish test in english locale """ input_dt = ["ä", "ö", "a", "e", "i", "o", "u"] expected = ["a", "ä", "e", "i", "o", "ö", "u"] - self.__collation_test (input_dt, expected) + self.__collation_test(input_dt, expected) if __name__ == "__main__": print(""" @@ -129,6 +131,4 @@ if __name__ == "__main__": * Check what happens in non-english encoding * Dynamic change of collation (not implemented yet in tracker) """) - ut.main () - - + ut.main() |