from LanguageHelper import LanguageHelper
import unittest

# We define the custom lexicon that we will use for our controlled tests
lexicon = ('car', 'cat', 'Cate', 'cater', 'care',
           'cot', 'cute', 'dare', 'date', 'dog', 'dodge',
           'coffee', 'pickle', 'grate')

class BasicTest(unittest.TestCase):

  def setUp(self):
    self.help = LanguageHelper(lexicon)

  # make sure that all the words in the lexicon are recognized
  def testContainment(self):
    for w in lexicon:
      self.assertTrue(w in self.help)

  def testFailures(self):
    self.assertFalse('cate' in self.help)     # only allowed when capitalized
    self.assertFalse('fox' in self.help)      # word is not there
    self.assertFalse('cofee' in self.help)    # mis-spell word is not there

  def testSuggestions(self):
    self.assertEqual(self.help.getSuggestions('cofee'), ['coffee'])
    self.assertEqual(self.help.getSuggestions('Gate'), ['Cate', 'Date', 'Grate'])
    self.assertEqual(self.help.getSuggestions('blech'), [])

if __name__ == '__main__':
  unittest.main()
