Example #1
0
    def test_from_yaml(self):
        yaml_data = yaml.load("""
        service:
            name: test
            category: test_category
            service_class: service.TestService
            default_response: Default Response
            default_srai: DEFAULT_SRAI
            default_aiml: test.aiml
        """,
                              Loader=yaml.FullLoader)

        config = ServiceConfiguration.new_from_yaml(yaml_data, "test.yaml")
        self.assertIsNotNone(config)
        self.assertIsInstance(config, ServiceConfiguration)

        self.assertEqual(config.service_type, 'generic')

        self.assertEqual("test", config.name)
        self.assertEqual("test_category", config.category)

        self.assertEqual("test.yaml", config.storage)

        self.assertEqual("service.TestService", config.service_class)

        self.assertEqual(config.default_response, "Default Response")
        self.assertEqual(config.default_srai, "DEFAULT_SRAI")
        self.assertEqual(config.default_aiml, "test.aiml")
Example #2
0
    def test_from_yaml_with_rest(self):
        yaml_data = yaml.load("""
        service:
            type: rest
            name: test
            category: test_category
            service_class: service.TestService
            default_response: Default Response
            default_srai: DEFAULT_SRAI
            default_aiml: test.aiml
            rest:
                retries: [10, 50, 100]
                timeout: 900
        """,
                              Loader=yaml.FullLoader)

        config = ServiceConfiguration.new_from_yaml(yaml_data, "test.yaml")
        self.assertIsNotNone(config)
        self.assertIsInstance(config, ServiceRESTConfiguration)

        self.assertEqual("test", config.name)
        self.assertEqual("test_category", config.category)

        self.assertEqual("test.yaml", config.storage)

        self.assertEqual("service.TestService", config.service_class)

        self.assertEqual(config.default_response, "Default Response")
        self.assertEqual(config.default_srai, "DEFAULT_SRAI")
        self.assertEqual(config.default_aiml, "test.aiml")

        self.assertEqual(config.retries, [10, 50, 100])
        self.assertEqual(config.timeout, 900)
Example #3
0
    def _load_conf_file(self, client_context, conf_file):
        with open(conf_file, 'r+', encoding="utf-8") as yml_data_file:
            yaml_data = yaml.load(yml_data_file, Loader=yaml.FullLoader)

            config = ServiceConfiguration.new_from_yaml(yaml_data, conf_file)

            client_context.brain.service_handler.load_service(config)

            client_context.brain.service_handler.post_initialise(client_context.brain)
Example #4
0
    def _process_service_yaml(self, handler, file, filename):
        yaml_data = yaml.load(file, Loader=yaml.FullLoader)

        configuration = ServiceConfiguration.new_from_yaml(yaml_data, filename)

        return handler.load_service(configuration)