How to use the autohooks.config.AutohooksConfig function in autohooks

To help you get started, we’ve selected a few autohooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github greenbone / autohooks / tests / test_config.py View on Github external
def test_missing_pre_commit(self):
        config = AutohooksConfig({'tool': {'autohooks': {'foo': 'bar'}}})

        self.assertTrue(config.has_config())
        self.assertTrue(config.has_autohooks_config())
        self.assertTrue(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.UNDEFINED)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_get_mode_pipenv(self):
        config = AutohooksConfig({'tool': {'autohooks': {'mode': 'pipenv'}}})

        self.assertTrue(config.has_config())
        self.assertTrue(config.has_autohooks_config())
        self.assertTrue(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.PIPENV)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_get_mode_unknown(self):
        config = AutohooksConfig({'tool': {'autohooks': {'mode': 'foo'}}})

        self.assertTrue(config.has_config())
        self.assertTrue(config.has_autohooks_config())
        self.assertTrue(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.UNKNOWN)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_empty_config_dict(self):
        config = AutohooksConfig({'foo': 'bar'})

        self.assertTrue(config.has_config())
        self.assertFalse(config.has_autohooks_config())
        self.assertFalse(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.UNDEFINED)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_get_mode_undefined(self):
        config = AutohooksConfig({'tool': {'autohooks': {'mode': None}}})

        self.assertTrue(config.has_config())
        self.assertTrue(config.has_autohooks_config())
        self.assertTrue(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.UNDEFINED)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_empty_config(self):
        config = AutohooksConfig()

        self.assertFalse(config.has_config())
        self.assertFalse(config.has_autohooks_config())
        self.assertFalse(config.is_autohooks_enabled())
        self.assertEqual(config.get_mode(), Mode.UNDEFINED)

        self.assertEqual(len(config.get_pre_commit_script_names()), 0)
github greenbone / autohooks / tests / test_config.py View on Github external
def test_get_config_dict(self):
        config_in = {'tool': {'autohooks': {'lorem': 'ipsum'}}, 'foo': 'bar'}
        config = AutohooksConfig(config_in)

        self.assertTrue(config.has_config())
        self.assertTrue(config.has_autohooks_config())
        self.assertEqual(config.get_mode(), Mode.UNDEFINED)

        config_out = config.get_config()

        self.assertEqual(config_out.get_value('foo'), 'bar')
github greenbone / autohooks / autohooks / config.py View on Github external
def from_pyproject_toml(pyproject_toml: Path = None) -> "AutohooksConfig":
        if pyproject_toml is None:
            pyproject_toml = get_pyproject_toml_path()

        if not pyproject_toml.exists():
            return AutohooksConfig()

        config_dict = tomlkit.loads(pyproject_toml.read_text())
        return AutohooksConfig(config_dict)
github greenbone / autohooks / autohooks / config.py View on Github external
def from_pyproject_toml(pyproject_toml: Path = None) -> "AutohooksConfig":
        if pyproject_toml is None:
            pyproject_toml = get_pyproject_toml_path()

        if not pyproject_toml.exists():
            return AutohooksConfig()

        config_dict = tomlkit.loads(pyproject_toml.read_text())
        return AutohooksConfig(config_dict)
github greenbone / autohooks / autohooks / config.py View on Github external
def load_config_from_pyproject_toml(
    pyproject_toml: Path = None,
) -> AutohooksConfig:
    return AutohooksConfig.from_pyproject_toml(pyproject_toml)