Beispiel #1
0
    def test_alldefault_lint(self):
        """Test lint command for default config"""
        lc = logConfig(lint=True)
        lc.configure()
        root = logging.getLogger()
        root.setLevel(logging.ERROR)

        config = RawConfigParser()

        mc = MainController(config)
        errors = mc.lint()
        self.assertEqual(
            2, errors,
            "With all default, 1 error for SAPlugin and 1 error for ClamavPlugin are expected"
        )
Beispiel #2
0
    def test_lint_nodefault(self):
        """Plugin with missing required var without default"""
        lc = logConfig(lint=True)
        lc.configure()
        root = logging.getLogger()
        root.setLevel(logging.ERROR)

        config = RawConfigParser()

        # -------------#
        # config: main #
        # -------------#
        config.add_section("main")
        config.set('main', 'plugins', 'controller_tests.Dummy3')
        config.set('main', 'prependers', '')
        config.set('main', 'appenders', '')

        mc = MainController(config)
        errors = mc.lint()
        self.assertEqual(1, errors)
Beispiel #3
0
    def test_lint_noproblems(self):
        """Test lint where config is all fine"""
        lc = logConfig(lint=True)
        lc.configure()
        root = logging.getLogger()
        root.setLevel(logging.ERROR)

        config = RawConfigParser()

        # -------------#
        # config: main #
        # -------------#
        config.add_section("main")
        config.set('main', 'plugins', 'controller_tests.Dummy2')
        config.set('main', 'prependers', '')
        config.set('main', 'appenders', '')

        mc = MainController(config)
        errors = mc.lint()
        self.assertEqual(0, errors)
Beispiel #4
0
    def test_lint_nosec(self):
        """Test if plugin with section=None triggers error by default"""
        lc = logConfig(lint=True)
        lc.configure()
        root = logging.getLogger()
        root.setLevel(logging.ERROR)

        config = RawConfigParser()

        # -------------#
        # config: main #
        # -------------#
        config.add_section("main")
        config.set('main', 'plugins',
                   'controller_tests.Dummy,controller_tests.Dummy2')
        config.set('main', 'prependers', '')
        config.set('main', 'appenders', '')

        mc = MainController(config)
        errors = mc.lint()
        self.assertEqual(1, errors)