]> kaliko git repositories - mpd-sima.git/commitdiff
Add unit test for simastr module
authorkaliko <efrim@azylum.org>
Wed, 11 Dec 2013 16:19:50 +0000 (17:19 +0100)
committerkaliko <efrim@azylum.org>
Mon, 27 Jan 2014 10:14:41 +0000 (11:14 +0100)
tests/__init__.py [new file with mode: 0644]
tests/test_simastr.py [new file with mode: 0644]

diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/test_simastr.py b/tests/test_simastr.py
new file mode 100644 (file)
index 0000000..c62af39
--- /dev/null
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+
+import sima.lib.simastr
+
+
+def fuzzystr(sta, stb):
+    afz = sima.lib.simastr.SimaStr(sta)
+    bfz = sima.lib.simastr.SimaStr(stb)
+    return afz == bfz
+
+
+
+class TestSequenceFunctions(unittest.TestCase):
+
+    def test_fuzzystr(self):
+        sima.lib.simastr.SimaStr.diafilter = False
+        self.assertFalse(fuzzystr('eeee', 'éééé'))
+        tests = [
+                ('eeee', 'éééé', self.assertTrue),
+                ('The Doors', 'Doors', self.assertTrue),
+                ('Tigres Del Norte', 'Los Tigres Del Norte', self.assertTrue),
+                (   'The Desert Sessions & PJ Harvey',
+                    'Desert Sessions And PJ Harvey',
+                    self.assertTrue
+                    ),
+                ]
+        sima.lib.simastr.SimaStr.diafilter = True
+        for sta, stb, assertfunc in tests:
+            assertfunc(fuzzystr(sta, stb), '"{0}" == "{1}"'.format(sta, stb))
+
+# vim: ai ts=4 sw=4 sts=4 expandtab
+