OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 import os, sys, unittest, types | 3 import os, sys, unittest, types |
4 import common | 4 import common |
5 from autotest_lib.client.common_lib import global_config | 5 from autotest_lib.client.common_lib import global_config |
6 from autotest_lib.client.common_lib import autotemp | 6 from autotest_lib.client.common_lib import autotemp |
7 | 7 |
8 | 8 |
9 global_config_ini_contents = """ | 9 global_config_ini_contents = """ |
10 [SECTION_A] | 10 [SECTION_A] |
(...skipping 17 matching lines...) Expand all Loading... |
28 shadow_config_ini_contents = """ | 28 shadow_config_ini_contents = """ |
29 [SECTION_C] | 29 [SECTION_C] |
30 value_1: somebody@remotehost | 30 value_1: somebody@remotehost |
31 """ | 31 """ |
32 | 32 |
33 | 33 |
34 def create_config_files(): | 34 def create_config_files(): |
35 global_temp = autotemp.tempfile("global", ".ini", | 35 global_temp = autotemp.tempfile("global", ".ini", |
36 text=True) | 36 text=True) |
37 os.write(global_temp.fd, global_config_ini_contents) | 37 os.write(global_temp.fd, global_config_ini_contents) |
38 os.close(global_temp.fd) | |
39 | 38 |
40 shadow_temp = autotemp.tempfile("shadow", ".ini", | 39 shadow_temp = autotemp.tempfile("shadow", ".ini", |
41 text=True) | 40 text=True) |
42 fd = shadow_temp.fd | 41 fd = shadow_temp.fd |
43 os.write(shadow_temp.fd, shadow_config_ini_contents) | 42 os.write(shadow_temp.fd, shadow_config_ini_contents) |
44 os.close(shadow_temp.fd) | |
45 | 43 |
46 return (global_temp, shadow_temp) | 44 return (global_temp, shadow_temp) |
47 | 45 |
48 | 46 |
49 class global_config_test(unittest.TestCase): | 47 class global_config_test(unittest.TestCase): |
50 # grab the singelton | 48 # grab the singelton |
51 conf = global_config.global_config | 49 conf = global_config.global_config |
52 | 50 |
53 def setUp(self): | 51 def setUp(self): |
54 # set the config files to our test files | 52 # set the config files to our test files |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 val = self.conf.get_config_value("MISSING", "foo", float, 3.6) | 114 val = self.conf.get_config_value("MISSING", "foo", float, 3.6) |
117 self.assertEquals(val, 3.6) | 115 self.assertEquals(val, 3.6) |
118 val = self.conf.get_config_value("SECTION_A", "novalue", str, | 116 val = self.conf.get_config_value("SECTION_A", "novalue", str, |
119 "default") | 117 "default") |
120 self.assertEquals(val, "default") | 118 self.assertEquals(val, "default") |
121 | 119 |
122 | 120 |
123 # this is so the test can be run in standalone mode | 121 # this is so the test can be run in standalone mode |
124 if __name__ == '__main__': | 122 if __name__ == '__main__': |
125 unittest.main() | 123 unittest.main() |
OLD | NEW |