forked from IBM/watson-stt-wer-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_config.py
46 lines (34 loc) · 1.54 KB
/
test_config.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
37
38
39
40
41
42
43
44
45
46
import unittest, os
from config import Config
def getInstance():
return Config('config.ini.sample')
class MyTest(unittest.TestCase):
def test_get_value(self):
c = getInstance()
self.assertEqual(c.getValue('SpeechToText','base_model_name'), 'en-US_NarrowbandModel')
def test_get_missing_section(self):
c = getInstance()
self.assertEqual(c.getValue('NotARealSection','NotARealKey'), None)
def test_get_missing_key(self):
c = getInstance()
self.assertEqual(c.getValue('SpeechToText', 'NotARealKey'), None)
def test_get_boolean_false(self):
c = getInstance()
self.assertEqual(c.getBoolean('SpeechToText', 'use_bearer_token'), False)
def test_get_boolean_true(self):
c = getInstance()
self.assertEqual(c.getBoolean('Transformations', 'remove_empty_strings'), True)
def test_get_value_with_percent(self):
c = getInstance()
self.assertEqual(c.getValue('Transformations','remove_word_list'), 'uh,uhuh,%hesitation,hesitation')
def test_set_value_with_key(self):
c = getInstance()
c.setValue('SpeechToText','smart_formatting', 'True')
self.assertEqual(c.getValue('SpeechToText', 'smart_formatting'), 'True')
def test_write_file(self):
c = getInstance()
c.writeFile('config.ini.unit_test')
self.assertEqual(Config('config.ini.unit_test').getValue('SpeechToText','base_model_name'), 'en-US_NarrowbandModel')
os.remove('config.ini.unit_test')
if __name__ == '__main__':
unittest.main()