56 config.configParser.remove_section(s) |
56 config.configParser.remove_section(s) |
57 |
57 |
58 @patch('iro.config.ConfigParser.read') |
58 @patch('iro.config.ConfigParser.read') |
59 def testMain(self,pRead): |
59 def testMain(self,pRead): |
60 sample_config = """[main] |
60 sample_config = """[main] |
61 hostname = localhost |
|
62 port = 8000 |
61 port = 8000 |
63 dburl = sdfdsafgsfdg |
62 dburl = sdfdsafgsfdg |
64 """ |
63 """ |
65 config.configParser.readfp(io.BytesIO(sample_config)) |
64 config.configParser.readfp(io.BytesIO(sample_config)) |
66 config.configParser.read([]) |
65 config.configParser.read([]) |
67 pRead.assert_called_once_with(config.configParser,[]) |
66 pRead.assert_called_once_with(config.configParser,[]) |
68 |
67 |
69 @patch('iro.config.ConfigParser.read') |
68 @patch('iro.config.ConfigParser.read') |
70 def testMainBadPort(self,pRead): |
69 def testMainBadPort(self,pRead): |
71 sample_config = """[main] |
70 sample_config = """[main] |
72 hostname = localhost |
|
73 port = -8000 |
71 port = -8000 |
74 dburl = sadfaserasg |
72 dburl = sadfaserasg |
75 """ |
73 """ |
76 config.configParser.readfp(io.BytesIO(sample_config)) |
74 config.configParser.readfp(io.BytesIO(sample_config)) |
77 self.assertRaises(error.ValidateException, config.configParser.read, []) |
75 self.assertRaises(error.ValidateException, config.configParser.read, []) |
78 |
76 |
79 @patch('iro.config.ConfigParser.read') |
77 @patch('iro.config.ConfigParser.read') |
80 def testMainNoMust(self,pRead): |
78 def testMainNoMust(self,pRead): |
81 sample_config = """[main] |
79 sample_config = """[main] |
82 port = 8000 |
80 port = 8000 |
83 dburl = asdfgdsrg |
|
84 """ |
81 """ |
85 config.configParser.readfp(io.BytesIO(sample_config)) |
82 config.configParser.readfp(io.BytesIO(sample_config)) |
86 self.assertRaises(config.NeededOption, config.configParser.read, []) |
83 self.assertRaises(config.NeededOption, config.configParser.read, []) |
87 |
84 |
88 @patch('iro.config.ConfigParser.read') |
85 @patch('iro.config.ConfigParser.read') |
89 def testMust(self,pRead): |
86 def testMust(self,pRead): |
90 v=Mock() |
87 v=Mock() |
91 config.main.options["test"] = config.Option(v) |
88 config.main.options["test"] = config.Option(v) |
92 try: |
89 try: |
93 sample_config = """[main] |
90 sample_config = """[main] |
94 hostname = localhost |
|
95 dburl = sdfawersdf |
91 dburl = sdfawersdf |
96 port = 8000 |
92 port = 8000 |
97 """ |
93 """ |
98 config.configParser.readfp(io.BytesIO(sample_config)) |
94 config.configParser.readfp(io.BytesIO(sample_config)) |
99 config.configParser.read([]) |
95 config.configParser.read([]) |
100 self.assertEqual(v.called,0) |
96 self.assertEqual(v.called,0) |
101 sample_config = """[main] |
97 sample_config = """[main] |
102 hostname = localhost |
|
103 dburl = adfgsdftsfg |
98 dburl = adfgsdftsfg |
104 port = 8000 |
99 port = 8000 |
105 test = foohu |
100 test = foohu |
106 """ |
101 """ |
107 config.configParser.readfp(io.BytesIO(sample_config)) |
102 config.configParser.readfp(io.BytesIO(sample_config)) |