def test_to_yaml_without_defaults(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text( """ socket: host: 127.0.0.1 port: 9999 queue: 5 max_buffer: 1024 debug: true bot: bot default_userid: console prompt: $ bot_selector: programy.clients.client.DefaultBotSelector renderer: programy.clients.render.text.TextRenderer """, ConsoleConfiguration(), ".") config = SocketConfiguration() config.load_configuration(yaml, ".") data = {} config.to_yaml(data, False) self.assertEqual("127.0.0.1", data['host']) self.assertEqual(9999, data['port']) self.assertEqual(5, data['queue']) self.assertEqual(1024, data['max_buffer']) self.assertEqual(True, data['debug']) self.assertEqual(data['bot'], 'bot') self.assertEqual(data['bot_selector'], "programy.clients.client.DefaultBotSelector") self.assertEqual(data['renderer'], "programy.clients.render.text.TextRenderer")
def test_to_yaml_no_data(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" other: """, ConsoleConfiguration(), ".") config = SocketConfiguration() config.load_configuration(yaml, ".") data = {} config.to_yaml(data, False) self.assertEqual("0.0.0.0", data['host']) self.assertEqual(80, data['port']) self.assertEqual(5, data['queue']) self.assertEqual(1024, data['max_buffer']) self.assertEqual(False, data['debug']) self.assertEqual(data['bot_selector'], "programy.clients.botfactory.DefaultBotSelector") self.assertEqual(data['renderer'], "programy.clients.render.text.TextRenderer") self.assertTrue('bots' in data) self.assertTrue('bot' in data['bots']) self.assertEqual(data['bot_selector'], "programy.clients.botfactory.DefaultBotSelector") self.assertTrue('brains' in data['bots']['bot']) self.assertTrue('brain' in data['bots']['bot']['brains'])
def test_to_yaml_with_defaults(self): config = SocketConfiguration() data = {} config.to_yaml(data, True) self.assertEqual("0.0.0.0", data['host']) self.assertEqual(80, data['port']) self.assertEqual(5, data['queue']) self.assertEqual(1024, data['max_buffer']) self.assertEqual(False, data['debug']) self.assertEqual(data['bot'], 'bot') self.assertEqual(data['bot_selector'], "programy.clients.client.DefaultBotSelector") self.assertEqual(data['renderer'], "programy.clients.render.text.TextRenderer")