forked from d4nj1/TLPUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unitests.py
36 lines (25 loc) · 1.05 KB
/
unitests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
from json import load
from configui import get_tlp_categories
from file import read_tlp_file_config, get_json_schema_object_from_file
def get_config_count(categories):
configcount = 0
for category in categories:
configs = category['configs']
configcount += len(configs);
return configcount
class MyTestCase(unittest.TestCase):
def test_config_categories(self):
configfilelist = read_tlp_file_config("/etc/default/tlp")
configfilecategories = get_tlp_categories(configfilelist)
self.assertEqual(len(configfilecategories), 12)
def test_tlp_file_vs_json_config(self):
# tlp file config
configfilelist = read_tlp_file_config("/etc/default/tlp")
# json config
jsoncategories = get_json_schema_object_from_file('categories', 'configschema.json')
jsonconfigcount = get_config_count(jsoncategories)
self.assertEqual(len(configfilelist), 80)
self.assertEqual(len(configfilelist), jsonconfigcount)
if __name__ == '__main__':
unittest.main()