8 class ConfigTest(unittest.TestCase):
11 self.tmpdir = tempfile.mkdtemp()
17 os.system("rm -fr '%s'" % self.tmpdir)
19 def test_read_config(self):
30 cf_file = os.path.join(self.tmpdir, 'config')
31 cf_fd = open(cf_file, 'w')
34 self.mox.StubOutWithMock(config.ca, 'CA', use_mock_anything=True)
35 config.ca.CA('root', {'something': 'else'}).AndReturn('ca')
36 self.mox.StubOutWithMock(config.cert, 'Cert', use_mock_anything=True)
37 config.cert.Cert('ca', 'cert1', {'cn': 'test.com'}).AndReturn('cert1')
40 global_config, ca_obj, certs = config.read_config(cf_file)
41 self.assertEquals('ca', ca_obj)
42 self.assertEquals(['cert1'], certs)
44 def test_read_config_nonexist(self):
46 config.read_config('nonexist.conf')
47 self.assertRaises(config.ConfigError, f)
50 if __name__ == '__main__':