# Path: chirp/library/similarity.py
# def canonicalize_string(txt):
# def get_sort_key(text):
# def get_levenshtein_distance(string_1, string_2, max_value=None):
# def get_common_prefix(string_1, string_2):


import unittest
from chirp.library import similarity
            (3, "abc", "xyz"),
            (3, "kitten", "sitting"),
            (3, "saturday", "sunday"),
            (9, "VERY", "different"))
        for expected_dist, string_1, string_2 in test_cases:
            dist = similarity.get_levenshtein_distance(string_1, string_2)
            self.assertEqual(expected_dist, dist, 
                             msg="(%s, %s)" % (string_1, string_2))
            dist = similarity.get_levenshtein_distance(string_2, string_1)
            self.assertEqual(expected_dist, dist,
                             msg="(%s, %s)" % (string_2, string_1))
            # Test setting max_value for many different values.
            for max_value in xrange(1, expected_dist+2):
                clamped_dist = similarity.get_levenshtein_distance(
                    string_1, string_2, max_value=max_value)
                self.assertEqual(min(expected_dist, max_value),
                                 clamped_dist)


class CommonPrefixTest(unittest.TestCase):

    def test_common_prefix(self):
        test_cases = (
            ("", "", ""),
            ("", "foo", ""),
            ("foo", "foo", "foo"),
            ("foo", "foo", "foobar"),
            ("foo", "fooxxx", "fooyyy"))
        for expected_prefix, string_1, string_2 in test_cases:
            self.assertEqual(expected_prefix,

# Path: chirp/library/similarity.py
# def canonicalize_string(txt):
# def get_sort_key(text):
# def get_levenshtein_distance(string_1, string_2, max_value=None):
# def get_common_prefix(string_1, string_2):


# Path: chirp/library/similarity_test.py
import unittest
from chirp.library import similarity

            (3, "abc", "xyz"),
            (3, "kitten", "sitting"),
            (3, "saturday", "sunday"),
            (9, "VERY", "different"))
        for expected_dist, string_1, string_2 in test_cases:
            dist = similarity.get_levenshtein_distance(string_1, string_2)
            self.assertEqual(expected_dist, dist, 
                             msg="(%s, %s)" % (string_1, string_2))
            dist = similarity.get_levenshtein_distance(string_2, string_1)
            self.assertEqual(expected_dist, dist,
                             msg="(%s, %s)" % (string_2, string_1))
            # Test setting max_value for many different values.
            for max_value in xrange(1, expected_dist+2):
                clamped_dist = similarity.get_levenshtein_distance(
                    string_1, string_2, max_value=max_value)
                self.assertEqual(min(expected_dist, max_value),
                                 clamped_dist)


class CommonPrefixTest(unittest.TestCase):

    def test_common_prefix(self):
        test_cases = (
            ("", "", ""),
            ("", "foo", ""),
            ("foo", "foo", "foo"),
            ("foo", "foo", "foobar"),
            ("foo", "fooxxx", "fooyyy"))
        for expected_prefix, string_1, string_2 in test_cases:
            self.assertEqual(expected_prefix,

                             similarity.get_common_prefix(string_1, string_2))