Example #1
0
    def test_to_yaml_with_defaults(self):
        config = XmppConfiguration()

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

        self.assertEqual(data['server'], "talk.google.com")
        self.assertEqual(data['port'], 5222)
        self.assertEqual(data['xep_0030'], True)
        self.assertEqual(data['xep_0004'], True)
        self.assertEqual(data['xep_0060'], True)
        self.assertEqual(data['xep_0199'], True)

        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'])
Example #2
0
    def execute(self, args):

        config_data = {}

        if args is None:
            raise Exception("Args empty")

        if args.clients is None:
            raise Exception("No clients defined")

        if 'all' in args.clients or 'console' in args.clients:
            self.add_to_config(config_data, ConsoleConfiguration(), args.defaults)

        if 'all' in args.clients or 'socket' in args.clients:
            self.add_to_config(config_data, SocketConfiguration(), args.defaults)

        if 'all' in args.clients or 'slack' in args.clients:
            self.add_to_config(config_data, SlackConfiguration(), args.defaults)

        if 'all' in args.clients or 'telegram' in args.clients:
            self.add_to_config(config_data, TelegramConfiguration(), args.defaults)

        if 'all' in args.clients or 'twitter' in args.clients:
            self.add_to_config(config_data, TwitterConfiguration(), args.defaults)

        if 'all' in args.clients or 'xmpp' in args.clients:
            self.add_to_config(config_data, XmppConfiguration(), args.defaults)

        if 'all' in args.clients or 'rest' in args.clients:
            self.add_to_config(config_data, RestConfiguration(name="rest"))

        if 'all' in args.clients or 'facebook' in args.clients:
            self.add_to_config(config_data, FacebookConfiguration(), args.defaults)

        if 'all' in args.clients or 'kik' in args.clients:
            self.add_to_config(config_data, KikConfiguration(), args.defaults)

        if 'all' in args.clients or 'line' in args.clients:
            self.add_to_config(config_data, LineConfiguration(), args.defaults)

        if 'all' in args.clients or 'twilio' in args.clients:
            self.add_to_config(config_data, TwilioConfiguration(), args.defaults)

        if 'all' in args.clients or 'viber' in args.clients:
            self.add_to_config(config_data, ViberConfiguration(), args.defaults)

        if 'all' in args.clients or 'sanic' in args.clients:
            self.add_to_config(config_data, SanicRestConfiguration(name="sanic"))

        client_config = ConsoleConfiguration()

        bot_config = client_config.configurations[0]

        self.add_to_config(config_data, bot_config, args.defaults)

        brain_config = bot_config.configurations[0]

        self.add_to_config(config_data, brain_config, args.defaults)

        self.write_yaml(args.file, config_data)
Example #3
0
    def test_register_plugins(self):
        bot_client = MockBotClient()
        xmpp_client = MockXmppClient(bot_client, "userid", "password")

        client_configuration = XmppConfiguration()
        client_configuration._xep_0030 = True
        client_configuration._xep_0004 = True
        client_configuration._xep_0060 = True
        client_configuration._xep_0199 = True

        xmpp_client.register_xep_plugins(client_configuration)

        self.assertTrue(bool("xep_0030" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0004" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0060" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0199" in xmpp_client.registered_plugins))
Example #4
0
 def get_client_configuration(self):
     config = XmppConfiguration()
     config._server = "Server"
     config._port = 8080
     config._xep_0030 = True
     config._xep_0004 = True
     config._xep_0060 = True
     config._xep_0199 = True
     return config
Example #5
0
    def test_to_yaml_with_defaults(self):
        config = XmppConfiguration()

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

        self.assertEquals(data['server'], "talk.google.com")
        self.assertEquals(data['port'], 5222)
        self.assertEquals(data['xep_0030'], True)
        self.assertEquals(data['xep_0004'], True)
        self.assertEquals(data['xep_0060'], True)
        self.assertEquals(data['xep_0199'], True)

        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")
Example #6
0
    def test_to_yaml_with_defaults(self):
        config = XmppConfiguration()

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

        self.assertEquals(data['server'], "talk.google.com")
        self.assertEquals(data['port'], 5222)
        self.assertEquals(data['xep_0030'], True)
        self.assertEquals(data['xep_0004'], True)
        self.assertEquals(data['xep_0060'], True)
        self.assertEquals(data['xep_0199'], True)

        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")
Example #7
0
 def get_client_configuration(self):
     config = XmppConfiguration()
     config._server = "Server"
     config._port = 8080
     config._xep_0030 = True
     config._xep_0004 = True
     config._xep_0060 = True
     config._xep_0199 = True
     return config
Example #8
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
            xmpp:
                server: talk.google.com
                port: 5222
                xep_0030: true
                xep_0004: true
                xep_0060: true
                xep_0199: true
        """, ConsoleConfiguration(), ".")

        xmpp_config = XmppConfiguration()
        xmpp_config.load_configuration(yaml, ".")

        self.assertEquals('talk.google.com', xmpp_config.server)
        self.assertEquals(5222, xmpp_config.port)
        self.assertTrue(xmpp_config.xep_0030)
        self.assertTrue(xmpp_config.xep_0004)
        self.assertTrue(xmpp_config.xep_0060)
        self.assertTrue(xmpp_config.xep_0199)
Example #9
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
            xmpp:
                server: talk.google.com
                port: 5222
                xep_0030: true
                xep_0004: true
                xep_0060: true
                xep_0199: true
        """, ConsoleConfiguration(), ".")

        xmpp_config = XmppConfiguration()
        xmpp_config.load_configuration(yaml, ".")

        self.assertEquals('talk.google.com', xmpp_config.server)
        self.assertEquals(5222, xmpp_config.port)
        self.assertTrue(xmpp_config.xep_0030)
        self.assertTrue(xmpp_config.xep_0004)
        self.assertTrue(xmpp_config.xep_0060)
        self.assertTrue(xmpp_config.xep_0199)
Example #10
0
    def test_register_plugins(self):
        bot_client = MockBotClient()
        xmpp_client = MockXmppClient(bot_client, "userid", "password")

        client_configuration = XmppConfiguration()
        client_configuration._xep_0030 = True
        client_configuration._xep_0004 = True
        client_configuration._xep_0060 = True
        client_configuration._xep_0199 = True

        xmpp_client.register_xep_plugins(client_configuration)

        self.assertTrue(bool("xep_0030" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0004" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0060" in xmpp_client.registered_plugins))
        self.assertTrue(bool("xep_0199" in xmpp_client.registered_plugins))
Example #11
0
 def get_client_configuration(self):
     return XmppConfiguration()