[tests] Add tests for soundex and levenshtein (related #128982)
authorSimon Chabot <simon.chabot@logilab.fr>
Wed, 17 Oct 2012 16:43:42 +0200
changeset 3 9bfce523ec42
parent 2 0b047ac20259
child 4 887a9c730bfc
[tests] Add tests for soundex and levenshtein (related #128982)
test/test_alignment.py
--- a/test/test_alignment.py	Wed Oct 17 16:42:48 2012 +0200
+++ b/test/test_alignment.py	Wed Oct 17 16:43:42 2012 +0200
@@ -38,10 +38,19 @@
 """
 
 from cubicweb.devtools import testlib
+from cubes.alignment.distances import (levenshtein, soundex)
 
-class DefaultTC(testlib.CubicWebTC):
-    def test_something(self):
-        self.skipTest('this cube has no test')
+class DistancesTest(testlib.CubicWebTC):
+    def test_levenshtein(self):
+        self.assertEqual(levenshtein('niche', 'chiens'), 5)
+        self.assertEqual(levenshtein('bonjour', 'bonjour !'), 2)
+        self.assertEqual(levenshtein('bon', 'bonjour'), 4)
+
+    def test_soundex(self):
+        self.assertEqual(soundex('Robert', 'english'), 'R163')
+        self.assertEqual(soundex('Rubert', 'english'), 'R163')
+        self.assertEqual(soundex('Rubin', 'english'), 'R150')
+        self.assertEqual(soundex('Ashcraft', 'english'), 'A226')
 
 
 if __name__ == '__main__':