def test_get_dict_id_with_the_same_word(self): d = _MetricsDictionary() word_id = d.get_dict_id("w") self.assertNotEqual(word_id, d.get_dict_id("w2")) self.assertNotEqual(word_id, d.get_dict_id("w3")) self.assertEqual(word_id, d.get_dict_id("w"))
def test_get_words(self): d = _MetricsDictionary() d.get_dict_id("3") d.get_dict_id("2") d.get_dict_id("1") words = d.get_words() self.assertEqual(3, len(words)) for i, word in enumerate(words, 1): self.assertEqual(str(i), word.word) self.assertEqual(3 - i, word.dict_id)
def test_get_words_with_empty_dict(self): d = _MetricsDictionary() words = d.get_words() self.assertEqual(0, len(words))
def test_get_dict_id_with_long_word(self): d = _MetricsDictionary() with self.assertRaises(ValueError): d.get_dict_id("a" * 1000)
def test_get_dict_id(self): d = _MetricsDictionary() for i in range(100): self.assertEqual(i, d.get_dict_id("w-%s" % i))