def test_discard(self):
     c = PrefixCache(Word, 'normalized_spelling')
     c.add(u'jkl')
     c.add(u'mno')
     c.add(u'mnp')
     self.assertEqual(sorted(c.items()),
                      [(u'jk', set([u'jkl'])),
                       (u'mn', set([u'mno', u'mnp']))])
     c.discard(u'jkl')
     c.discard(u'mno')
     self.assertEqual(c.items(), [(u'mn', set([u'mnp'])),
                                  (u'jk', set([]))])
 def test_contains(self):
     c = PrefixCache(Word, 'normalized_spelling')
     c.seed([u'ab-starting-words'])
     self.assertEqual(c.items(), [(u'ab', set([u'abc']))])
     self.assertTrue(c.contains(u'abc'))
     self.assertTrue(c.contains(u'efg'))
     self.assertEqual(c.items(), [(u'ab', set([u'abc'])),
                                  (u'ef', set([u'efg']))])
 def test_instances_with_prefix(self):
     c = PrefixCache(Word, 'normalized_spelling')
     words = c._instances_with_prefix(u'ab')
     self.assertEqual(list(words), [self.abc])
 def test_add(self):
     c = PrefixCache(Word, 'normalized_spelling')
     c.add(u'ghi')
     self.assertEqual(c.items(), [(u'gh', set([u'ghi']))])
 def test_seed(self):
     c = PrefixCache(Word, 'normalized_spelling')
     c.seed([u'abx', u'efh'])
     self.assertEqual(sorted(c.items()),
                      [(u'ab', set([u'abc'])),
                       (u'ef', set([u'efg']))])
 def test_seed_with_no_values(self):
     c = PrefixCache(Word, 'normalized_spelling')
     c.seed([])
     self.assertEqual(c.items(), [])