From d77d01cd2299a46d4cad95bfadf923d7b2133360 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 13 Mar 2014 19:38:52 -0700 Subject: [PATCH] Rename RepoInstaller to Repository --- .../{repo_installer.py => repository.py} | 2 +- tests/repo_installer_test.py | 62 ------------------- tests/repository_test.py | 42 +++++++++++++ 3 files changed, 43 insertions(+), 63 deletions(-) rename pre_commit/{repo_installer.py => repository.py} (97%) delete mode 100644 tests/repo_installer_test.py create mode 100644 tests/repository_test.py diff --git a/pre_commit/repo_installer.py b/pre_commit/repository.py similarity index 97% rename from pre_commit/repo_installer.py rename to pre_commit/repository.py index 9ec0673c..3ec61263 100644 --- a/pre_commit/repo_installer.py +++ b/pre_commit/repository.py @@ -5,7 +5,7 @@ from plumbum import local from pre_commit.hooks_workspace import in_hooks_workspace -class RepoInstaller(object): +class Repository(object): def __init__(self, repo_config): self.repo_config = repo_config diff --git a/tests/repo_installer_test.py b/tests/repo_installer_test.py deleted file mode 100644 index 12c89c33..00000000 --- a/tests/repo_installer_test.py +++ /dev/null @@ -1,62 +0,0 @@ -import os - -import jsonschema -import pytest -from pre_commit import git - -import pre_commit.constants as C -from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA -from pre_commit.repo_installer import RepoInstaller - - -@pytest.fixture -def dummy_repo_config(dummy_git_repo): - # This is not a valid config, but it is pretty close - return { - 'repo': dummy_git_repo, - 'sha': git.get_head_sha(dummy_git_repo), - 'hooks': [], - } - - -@pytest.mark.integration -def test_create_repo_in_env(dummy_repo_config, dummy_git_repo): - repo_installer = RepoInstaller(dummy_repo_config) - repo_installer.create() - - assert os.path.exists( - os.path.join(dummy_git_repo, C.HOOKS_WORKSPACE, repo_installer.sha), - ) - -@pytest.mark.integration -def test_install_python_repo_in_env(python_pre_commit_git_repo, config_for_python_pre_commit_git_repo): - repo_installer = RepoInstaller(config_for_python_pre_commit_git_repo) - # TODO: do we need create here? - repo_installer.install() - - assert os.path.exists( - os.path.join( - python_pre_commit_git_repo, - C.HOOKS_WORKSPACE, - repo_installer.sha, - 'py_env', - ), - ) - - -@pytest.fixture -def simple_config(python_pre_commit_git_repo): - config = [ - { - 'repo': python_pre_commit_git_repo, - 'sha': git.get_head_sha(python_pre_commit_git_repo), - 'hooks': [ - { - 'id': 'foo', - 'files': '*.py', - }, - ], - }, - ] - jsonschema.validate(config, CONFIG_JSON_SCHEMA) - return config diff --git a/tests/repository_test.py b/tests/repository_test.py new file mode 100644 index 00000000..78e86181 --- /dev/null +++ b/tests/repository_test.py @@ -0,0 +1,42 @@ +import os + +import pytest +from pre_commit import git + +import pre_commit.constants as C +from pre_commit.repository import Repository + + +@pytest.fixture +def dummy_repo_config(dummy_git_repo): + # This is not a valid config, but it is pretty close + return { + 'repo': dummy_git_repo, + 'sha': git.get_head_sha(dummy_git_repo), + 'hooks': [], + } + + +@pytest.mark.integration +def test_create_repo_in_env(dummy_repo_config, dummy_git_repo): + repo = Repository(dummy_repo_config) + repo.create() + + assert os.path.exists( + os.path.join(dummy_git_repo, C.HOOKS_WORKSPACE, repo.sha), + ) + +@pytest.mark.integration +def test_install_python_repo_in_env(python_pre_commit_git_repo, config_for_python_pre_commit_git_repo): + repo = Repository(config_for_python_pre_commit_git_repo) + # TODO: do we need create here? + repo.install() + + assert os.path.exists( + os.path.join( + python_pre_commit_git_repo, + C.HOOKS_WORKSPACE, + repo.sha, + 'py_env', + ), + )