Ejemplo n.º 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"))
Ejemplo n.º 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)
Ejemplo n.º 3
0
    def test_get_words_with_empty_dict(self):
        d = _MetricsDictionary()

        words = d.get_words()
        self.assertEqual(0, len(words))
Ejemplo n.º 4
0
    def test_get_dict_id_with_long_word(self):
        d = _MetricsDictionary()

        with self.assertRaises(ValueError):
            d.get_dict_id("a" * 1000)
Ejemplo n.º 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))