예제 #1
0
    def test_to_yaml_with_defaults(self):
        config = ViberConfiguration()

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

        self.assertEquals(data['name'], "ProgramY")
        self.assertEquals(data['avatar'], 'http://666666666.ngrok.io/programy.png')
        self.assertEquals(data['webhook'], 'http://666666666.ngrok.io/rest/v1.0/ask')

        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")
예제 #2
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        viber:
        """, ConsoleConfiguration(), ".")

        viber_config = ViberConfiguration()
        viber_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", viber_config.host)
        self.assertEqual(80, viber_config.port)
        self.assertEqual(False, viber_config.debug)
        self.assertIsNone(viber_config.name)
        self.assertIsNone(viber_config.avatar)
        self.assertIsNone(viber_config.webhook)
예제 #3
0
    def test_init_no_values(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        viber:
        """, ConsoleConfiguration(), ".")

        viber_config = ViberConfiguration()
        viber_config.load_configuration(yaml, ".")

        self.assertEqual("0.0.0.0", viber_config.host)
        self.assertEqual(80, viber_config.port)
        self.assertEqual(False, viber_config.debug)
        self.assertIsNone(viber_config.name)
        self.assertIsNone(viber_config.avatar)
        self.assertIsNone(viber_config.webhook)
예제 #4
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)
예제 #5
0
    def test_init(self):
        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text("""
        viber:
          host: 127.0.0.1
          port: 5000
          debug: false
          name: test
          avatar: avatar.jpg
          webhook: http://localhost
        """, ConsoleConfiguration(), ".")

        viber_config = ViberConfiguration()
        viber_config.load_configuration(yaml, ".")

        self.assertEqual("127.0.0.1", viber_config.host)
        self.assertEqual(5000, viber_config.port)
        self.assertEqual(False, viber_config.debug)
        self.assertEqual("test", viber_config.name)
        self.assertEqual("avatar.jpg", viber_config.avatar)
        self.assertEqual("http://localhost", viber_config.webhook)
예제 #6
0
    def test_to_yaml_with_defaults(self):
        config = ViberConfiguration()

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

        self.assertEqual(data['name'], "Program-Y")
        self.assertEqual(data['avatar'], 'http://127.0.0.1/programy.png')
        self.assertEqual(data['webhook'],
                         'https://127.0.0.1/api/viber/v1.0/ask')

        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'])
예제 #7
0
파일: client.py 프로젝트: rkc007/program-y
 def get_client_configuration(self):
     return ViberConfiguration()