Exemple #1
0
    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"))
Exemple #2
0
    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)
Exemple #3
0
    def test_get_words_with_empty_dict(self):
        d = _MetricsDictionary()

        words = d.get_words()
        self.assertEqual(0, len(words))
Exemple #4
0
    def test_get_dict_id_with_long_word(self):
        d = _MetricsDictionary()

        with self.assertRaises(ValueError):
            d.get_dict_id("a" * 1000)
Exemple #5
0
    def test_get_dict_id(self):
        d = _MetricsDictionary()

        for i in range(100):
            self.assertEqual(i, d.get_dict_id("w-%s" % i))