Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
def test_get_effective_mode(self):
self.assertEqual(Mode.PIPENV.get_effective_mode(), Mode.PIPENV)
self.assertEqual(Mode.PYTHONPATH.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.POETRY.get_effective_mode(), Mode.POETRY)
self.assertEqual(Mode.UNDEFINED.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.UNKNOWN.get_effective_mode(), Mode.PYTHONPATH)
def test_get_pipenv_mode_from_string(self):
self.assertEqual(Mode.from_string('pipenv'), Mode.PIPENV)
self.assertEqual(Mode.from_string('PIPENV'), Mode.PIPENV)
def test_get_poetry_mode_from_string(self):
self.assertEqual(Mode.from_string('poetry'), Mode.POETRY)
self.assertEqual(Mode.from_string('POETRY'), Mode.POETRY)
def test_get_poetry_mode_from_string(self):
self.assertEqual(Mode.from_string('poetry'), Mode.POETRY)
self.assertEqual(Mode.from_string('POETRY'), Mode.POETRY)
def test_get_pipenv_mode_from_string(self):
self.assertEqual(Mode.from_string('pipenv'), Mode.PIPENV)
self.assertEqual(Mode.from_string('PIPENV'), Mode.PIPENV)
def test_get_invalid_mode_from_string(self):
self.assertEqual(Mode.from_string('foo'), Mode.UNKNOWN)
self.assertEqual(Mode.from_string(None), Mode.UNDEFINED)
self.assertEqual(Mode.from_string(''), Mode.UNDEFINED)
def test_get_invalid_mode_from_string(self):
self.assertEqual(Mode.from_string('foo'), Mode.UNKNOWN)
self.assertEqual(Mode.from_string(None), Mode.UNDEFINED)
self.assertEqual(Mode.from_string(''), Mode.UNDEFINED)
def test_get_pythonpath_mode_from_string(self):
self.assertEqual(Mode.from_string('pythonpath'), Mode.PYTHONPATH)
self.assertEqual(Mode.from_string('PYTHONPATH'), Mode.PYTHONPATH)
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)