Ejemplo n.º 1
0
def get(handler, response):
  # redirect to emendapp.com
  if not is_dev() and environ.get('HTTP_HOST') == 'emend.appspot.com':
    return handler.redirect('http://www.emendapp.com?'+environ['QUERY_STRING'])
  # get params
  response.url = handler.request.get('url')
  response.original = handler.request.get('original')
  response.proposal = handler.request.get('proposal') or response.original
  response.original_eq_proposal = response.proposal == response.original
  # get a suggestion
  if response.original:
    try:
      response.suggestion = suggest(response.original)
    except KeyError, e:
      logging.warn('Missing credentials: %s', e)
Ejemplo n.º 2
0
 def test_no_suggestion(self):
     self.assertEquals(suggest(query=u"nothing to suggest"), None)
Ejemplo n.º 3
0
 def test_combination(self):
     query = u"it's a ant"
     expected = u"its an ant"
     suggestion = suggest(query=query)
     self.assertEquals(suggestion, expected)
Ejemplo n.º 4
0
 def test_a_vowel_sound(self):
     query = u"a ant"
     expected = u"an ant"
     suggestion = suggest(query=query)
     self.assertEquals(suggestion, expected)
Ejemplo n.º 5
0
 def test_apostrophe_s_unicode(self):
     query = u"in my 20’s"
     expected = u"in my 20s"
     suggestion = suggest(query=query)
     self.assertEquals(suggestion, expected)
Ejemplo n.º 6
0
 def test_spelling(self):
     query = u"Lunar Reconnoissance Orbiter"
     expected = u"Lunar Reconnaissance Orbiter"
     suggestion = suggest(query=query)
     self.assertEquals(suggestion, expected)
Ejemplo n.º 7
0
 def test_ascii_fails(self):
     self.failUnlessRaises(TypeError, lambda: suggest("ascii"))