Beispiel #1
0
 def test_multiple_datasources(self):
     self.set_file_with('multiple_datasources')
     config = PluginConfig('pyetl', 'pcaudit', ConfigFileLoader)
     config = config.load()
     self.assertIn('datasources', config)
     for section in ('opsi', 'itop'):
         self.assertIn(section, config['datasources'])
         self.assertIn('username', config['datasources'][section])
Beispiel #2
0
 def test_2(self):
     config = PluginConfig('pyetl', 'pcaudit', ConfigTextLoader)
     ctx = ExecContext.from_dict(config.load(self.full_data))
     result = ctx["opsi"]
     expected = {
         'username': '******',
         'password': '******'
     }
     self.assertDictEqual(expected, result)
Beispiel #3
0
    def test_file_not_found(self):
        config = PluginConfig('pyetl', 'pcaudit', ConfigFileLoader)
        with self.assertRaises(FileNotFoundError) as cm:
            _ = config.load()

        self.assertIn(
            "No file named 'pyetl.config.toml' "
            "can be located at these locations:",
            str(cm.exception)
        )
Beispiel #4
0
    def test_bad_structure_no_app_section(self):

        self.set_file_with('no_app_section')
        config = PluginConfig('pyetl', 'pcaudit', ConfigFileLoader)
        with self.assertRaises(RuntimeError) as cm:
            _ = config.load()
        self.assertIn(
            'Invalid structure of the configuration file '
            'for application pyetl: no section [pyetl]',
            str(cm.exception)
        )
Beispiel #5
0
    def test_config_plugin(self):

        self.set_file_with('nominal')

        config = PluginConfig('pyetl', 'pcaudit', ConfigFileLoader)
        config = config.load()
        self.assertIsInstance(config, dict)
        self.assertEqual(2, len(config))
        self.assertIn('a_key', config)
        self.assertIn('url', config)
        self.assertEqual(config['url'], 'bar.ru')
Beispiel #6
0
 def test_1(self):
     config = PluginConfig('pyetl', 'pcaudit', ConfigTextLoader)
     ctx = ExecContext.from_dict(config.load(self.full_data))
     result = ctx["itop"]
     expected = {
         'username': '******',
         'password': '******',
         'url': 'https://itsm-dev.escolan.recia.fr',
         'version': '1.3',
     }
     self.assertDictEqual(expected, result)
Beispiel #7
0
    def test_bad_structure_no_plugins_section(self):

        self.set_file_with('no_section_plugins')
        config = PluginConfig('pyetl', 'pcaudit', ConfigFileLoader)
        with self.assertRaises(RuntimeError) as cm:
            _ = config.load()
        self.assertIn(
            "Invalid structure of the configuration file for application "
            "pyetl: no section [plugins] or plugin's section "
            "[plugins.pcaudit]",
            str(cm.exception)
        )
Beispiel #8
0
 def test_6(self):
     config = PluginConfig('pyetl', 'pcaudit', ConfigPackageLoader)
     config = config.load(package_name='tests.fixtures')
     ctx = ExecContext.from_dict(config)
     result = ctx.itop.version
     self.assertEqual('1.3', result)
Beispiel #9
0
    def test_5(self):
        config = PluginConfig('pyetl', 'pcaudit', ConfigTextLoader)

        ctx = ExecContext.from_dict(config.load(self.full_data))
        result = ctx.itop.version
        self.assertEqual('1.3', result)
Beispiel #10
0
 def test_4(self):
     config = PluginConfig('pyetl', 'pcaudit', ConfigTextLoader)
     ctx = ExecContext.from_dict(config.load(self.full_data))
     with self.assertRaises(TypeError):
         _ = ctx["opsi.username.wrong"]
Beispiel #11
0
 def test_3(self):
     config = PluginConfig('pyetl', 'pcaudit', ConfigTextLoader)
     ctx = ExecContext.from_dict(config.load(self.full_data))
     with self.assertRaises(KeyError):
         _ = ctx["unknown"]