コード例 #1
0
ファイル: test_factory.py プロジェクト: LombeC/program-r
 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)
コード例 #2
0
ファイル: test_factory.py プロジェクト: LombeC/program-r
 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")
コード例 #3
0
ファイル: test_factory.py プロジェクト: LombeC/program-r
 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)
コード例 #4
0
ファイル: client.py プロジェクト: LombeC/program-r
    def load_configuration(self, arguments):
        if arguments.bot_root is None:
            if arguments.config_filename is not None:
                arguments.bot_root = os.path.dirname(arguments.config_filename)
            else:
                arguments.bot_root = "."

        if arguments.config_filename is not None:
            self._configuration = ConfigurationFactory.load_configuration_from_file(
                self.get_client_configuration(), arguments.config_filename,
                arguments.config_format, arguments.bot_root)
        else:
            print("No configuration file specified, using defaults only !")
            self._configuration = ProgramrConfiguration(
                self.get_client_configuration())
コード例 #5
0
ファイル: test_now_ask_me.py プロジェクト: LombeC/program-r
 def load_configuration(self, arguments):
     self._configuration = ConfigurationFactory.load_configuration_from_file(
         ConsoleConfiguration(),
         os.path.dirname(__file__) + os.sep + "testconfig.yaml",
         bot_root=os.path.dirname(__file__))
コード例 #6
0
ファイル: test_load_files.py プロジェクト: LombeC/program-r
 def test_load_config_data_xml(self):
     config_data = ConfigurationFactory.load_configuration_from_file(
         ConsoleConfiguration(),
         os.path.dirname(__file__) + os.sep + "test_xml.xml")
     self.assert_configuration(config_data)
コード例 #7
0
ファイル: test_factory.py プロジェクト: LombeC/program-r
 def test_guess_format_no_extension(self):
     with self.assertRaises(Exception):
         ConfigurationFactory.guess_format_from_filename("file_yaml")