Beispiel #1
0
    def test_to_yaml_without_defaults(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          bot: bot
          default_userid: console
          prompt: $
          license_keys: ./config/license.keys
          bot_selector: programy.clients.client.DefaultBotSelector
          renderer: programy.clients.render.text.TextRenderer
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        data = {}
        config.to_yaml(data, False)

        self.assertEquals('console', data['default_userid'])
        self.assertEquals('$', data['prompt'])

        self.assertEquals(data['bot'], 'bot')
        self.assertEquals(data['license_keys'], "./config/license.keys")
        self.assertEquals(data['bot_selector'], "programy.clients.client.DefaultBotSelector")
        self.assertEquals(data['renderer'], "programy.clients.render.text.TextRenderer")
Beispiel #2
0
    def test_to_yaml_without_defaults(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
        console:
          bot: bot
          default_userid: console
          prompt: $
          bot_selector: programy.clients.client.DefaultBotSelector
          renderer: programy.clients.render.text.TextRenderer
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        data = {}
        config.to_yaml(data, False)

        self.assertEqual('console', data['default_userid'])
        self.assertEqual('$', data['prompt'])

        self.assertEqual(data['bot'], 'bot')
        self.assertEqual(data['bot_selector'],
                         "programy.clients.client.DefaultBotSelector")
        self.assertEqual(data['renderer'],
                         "programy.clients.render.text.TextRenderer")
Beispiel #3
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertIsNotNone(config.configurations)
        self.assertEqual(1, len(config.configurations))
Beispiel #4
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertIsNotNone(config.configurations)
        self.assertEquals(1, len(config.configurations))
Beispiel #5
0
    def test_to_yaml_no_data(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        other:
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        data = {}
        config.to_yaml(data, False)

        self.assertEqual('console', data['default_userid'])
        self.assertEqual('>>>', data['prompt'])
Beispiel #6
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          default_userid: console
          prompt: $
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertEqual("console", config.default_userid)
        self.assertEqual("$", config.prompt)

        self.assertIsNotNone(config.configurations)
        self.assertEqual(1, len(config.configurations))
        self.assertIsInstance(config.configurations[0], BotConfiguration)
Beispiel #7
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        console:
          bot: bot
          default_userid: console
          prompt: $
        """, ConsoleConfiguration(), ".")

        config = ConsoleConfiguration()
        config.load_configuration(yaml, ".")

        self.assertEquals("console", config.default_userid)
        self.assertEquals("$", config.prompt)

        self.assertIsNotNone(config.configurations)
        self.assertEquals(1, len(config.configurations))
        self.assertIsInstance(config.configurations[0], BotConfiguration)