def test_find_shortest(): things = TSTree() things.set('apple', 'Apple') things.set('application', 'Application') things.set('applaus', 'Applaus') things.set('applicant', 'Applicant') assert things.find_shortest('appl') == "Apple" return things
class TSTRouter(URLRouter): def __init__(self): self.urls = TSTree() def add(self, key, value): self.urls.set(key, value) def match_url(self, url_to_find): return self.urls.get(url_to_find) def url_starts_with(self, url_to_find): return self.urls.find_all(url_to_find) def shortest_url(self, url_to_find): return self.urls.find_shortest(url_to_find) def longest_url(self, url_to_find): return self.urls.find_longest(url_to_find)