def test_clients_conf_simple(self): CP = ClientConfParser(content=CLIENT_CONF) config = CP.get_dict() print config self.assertTrue("localhost" in config) self.assertTrue("private-network-1" in config) self.assertEqual(config.get("private-network-1").get("secret"), "testing123-1") self.assertEqual(config.get("private-network-1").get("shortname"), "private-network-1")
def test_save_file(self): tmpfile = "./tmp-output" CP = ClientConfParser(content=CLIENT_CONF_ORIG) config = CP.get_dict() print config CP.save(config, tmpfile) f = open(tmpfile, "r") output = f.read() f.close() os.unlink(tmpfile) print output self.assertEqual(output, FILEOUTPUT_ORIG)
def test_clients_conf_original(self): CP = ClientConfParser(content=CLIENT_CONF_ORIG) config = CP.get_dict() print config # {'127.0.0.1': {'secret': 'testing123', 'shortname': 'localhost', # 'nastype': 'other '}} self.assertTrue("localhost" not in config) self.assertTrue("127.0.0.1" in config) self.assertEqual(config.get("127.0.0.1").get("secret"), "testing123") self.assertEqual(config.get("127.0.0.1").get("nastype"), "other") output = CP.format(config) print output self.assertEqual(output, FILEOUTPUT_ORIG)
def test_read_clients_from_file(self): CP = ClientConfParser(infile="./testdata/clients.conf") config = CP.get() self.assertEqual(len(config), 2)