source: git/machine_learning/tests/common/test_lookuptable.py @ 50e872

spielwiese
Last change on this file since 50e872 was 50e872, checked in by Murray Heymann <heymann.murray@…>, 5 years ago
Finish migrating to unittest framework
  • Property mode set to 100644
File size: 1.1 KB
Line 
1import os
2import unittest
3import numpy as np
4
5from common.lookuptable import *
6from common.constants import KEYWORDS_FILE
7
8class TestLookuptableMethods(unittest.TestCase):
9
10    def test_get_list_of_htm_files(self):
11        os.system("rm -r " + HELP_FILE_PATH)
12        fetch_tbz2_data()
13        fetch_tbz2_data()
14        files = get_list_of_htm_files()
15        self.assertGreater(len(files), 0)
16
17    def test_extract_keywords(self):
18        extract_keywords()
19        self.assertTrue(os.path.isfile(KEYWORDS_FILE))
20
21    def test_create_table(self):
22        dictionary = read_dictionary(KEYWORDS_FILE)
23        vectors, files = create_table(dictionary, attempt_cached=False)
24        vectors1, files1 = create_table()
25        self.assertTrue((vectors == vectors1).all())
26        self.assertTrue((files == files1).all())
27
28        dictionary = read_dictionary(KEYWORDS_FILE)
29        test_vec = count_occurances(os.path.join(HELP_FILE_PATH, "html",
30                                                 files[1]), dictionary)
31        self.assertTrue((test_vec == vectors[1]).all())
32
33if __name__ == '__main__':
34    unittest.main()
Note: See TracBrowser for help on using the repository browser.