diff --git a/pre_commit/clientlib/validate_config.py b/pre_commit/clientlib/validate_config.py index 241816ba..2938c7f4 100644 --- a/pre_commit/clientlib/validate_config.py +++ b/pre_commit/clientlib/validate_config.py @@ -41,7 +41,7 @@ CONFIG_JSON_SCHEMA = { } -validate_manifest = get_validator( +validate_config = get_validator( C.CONFIG_FILE, CONFIG_JSON_SCHEMA, InvalidConfigError, @@ -60,7 +60,7 @@ def run(argv): args = parser.parse_args(argv) try: - validate_manifest(args.filename) + validate_config(args.filename) except InvalidConfigError as e: print(e.args[0]) # If we have more than one exception argument print the stringified diff --git a/tests/installer/repo_installer_test.py b/tests/installer/repo_installer_test.py index bfa304dd..e323b084 100644 --- a/tests/installer/repo_installer_test.py +++ b/tests/installer/repo_installer_test.py @@ -1,8 +1,10 @@ +import jsonschema import pytest import os +from plumbum import local import pre_commit.constants as C -from plumbum import local +from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA from pre_commit.installer.repo_installer import create_repo_in_env from pre_commit.installer.repo_installer import install_pre_commit @@ -26,9 +28,8 @@ def test_install_python_repo_in_env(empty_git_dir, python_pre_commit_git_repo): assert os.path.exists(os.path.join(python_pre_commit_git_repo, C.PRE_COMMIT_DIR, sha, 'py_env')) -@pytest.mark.integration -def test_install_config(empty_git_dir, python_pre_commit_git_repo): - +@pytest.fixture +def simple_config(python_pre_commit_git_repo): config = [ { 'repo': python_pre_commit_git_repo, @@ -36,17 +37,24 @@ def test_install_config(empty_git_dir, python_pre_commit_git_repo): 'hooks': [ { 'id': 'foo', - 'args': [ - { - 'type': 'files', - 'opt': '*.py' - }, - ] - } + 'files': '*.py', + } ], - }, - ] - for repo in config: + }, + ] + jsonschema.validate(config, CONFIG_JSON_SCHEMA) + return config + + +@pytest.mark.integration +def test_install_config(empty_git_dir, python_pre_commit_git_repo, simple_config): + for repo in simple_config: install_pre_commit(repo['repo'], repo['sha']) - assert os.path.exists(os.path.join(python_pre_commit_git_repo, C.PRE_COMMIT_DIR, config[0]['sha'], 'py_env')) \ No newline at end of file + assert os.path.exists( + os.path.join( + python_pre_commit_git_repo, + C.PRE_COMMIT_DIR, simple_config[0]['sha'], + 'py_env', + ), + ) \ No newline at end of file