Beispiel #1
0
 def test_get_config_by_name(self):
     config_type = ConfigurationFactory.get_config_by_name("yaml")
     self.assertIsNotNone(config_type)
     config_type = ConfigurationFactory.get_config_by_name("json")
     self.assertIsNotNone(config_type)
     config_type = ConfigurationFactory.get_config_by_name("xml")
     self.assertIsNotNone(config_type)
Beispiel #2
0
 def test_guess_format_from_filename(self):
     config_format = ConfigurationFactory.guess_format_from_filename("file.yaml")
     self.assertEqual(config_format, "yaml")
     config_format = ConfigurationFactory.guess_format_from_filename("file.json")
     self.assertEqual(config_format, "json")
     config_format = ConfigurationFactory.guess_format_from_filename("file.xml")
     self.assertEqual(config_format, "xml")
Beispiel #3
0
 def test_get_config_by_name(self):
     client_config = ClientConfiguration()
     config_type = ConfigurationFactory.get_config_by_name(client_config, "yaml")
     self.assertIsNotNone(config_type)
     config_type = ConfigurationFactory.get_config_by_name(client_config, "json")
     self.assertIsNotNone(config_type)
     config_type = ConfigurationFactory.get_config_by_name(client_config, "xml")
     self.assertIsNotNone(config_type)
Beispiel #4
0
    def load_configuration(self, arguments):
        if arguments.bot_root is None:
            arguments.bot_root = os.path.dirname(arguments.config_filename)
            print("No bot root argument set, defaulting to [%s]" %
                  arguments.bot_root)

        self.configuration = self.get_client_configuration()

        ConfigurationFactory.load_configuration_from_file(
            self.configuration, arguments.config_filename,
            arguments.config_format, arguments.bot_root)
Beispiel #5
0
 def test_get_config_by_name_wrong_extension(self):
     with self.assertRaises(Exception):
         ConfigurationFactory.get_config_by_name("other")
     with self.assertRaises(Exception):
         ConfigurationFactory.get_config_by_name("")
     with self.assertRaises(Exception):
         ConfigurationFactory.get_config_by_name(None)
Beispiel #6
0
 def test_load_config_data_xml(self):
     client_config = ClientConfiguration()
     ConfigurationFactory.load_configuration_from_file(
         client_config,
         os.path.dirname(__file__) + "/test_xml.xml")
     self.assert_config_data(client_config)
Beispiel #7
0
 def test_guess_format_no_extension(self):
     with self.assertRaises(Exception):
         ConfigurationFactory.guess_format_from_filename("file_yaml")
Beispiel #8
0
 def load_configuration(self, arguments):
     self.configuration = ClientConfiguration()
     ConfigurationFactory.load_configuration_from_file(
         self.configuration,
         os.path.dirname(__file__) + "/test_files/train/testconfig.yaml")
Beispiel #9
0
 def load_configuration(self, arguments):
     self.configuration = ConfigurationFactory.load_configuration_from_file(
         arguments.config_filename, arguments.config_format)
Beispiel #10
0
 def test_load_config_data_xml(self):
     config_data = ConfigurationFactory.load_configuration_from_file(
         "test_xml.xml")
     self.assert_config_data(config_data)
Beispiel #11
0
 def test_load_config_data_json(self):
     config_data = ConfigurationFactory.load_configuration_from_file(
         "test_json.json")
     self.assert_config_data(config_data)