From 1ecbf30c21d6f7b2021074cfdac9994fbdcbe2c9 Mon Sep 17 00:00:00 2001 From: "rodrigo.rezino" Date: Sat, 4 Dec 2021 13:42:21 +0100 Subject: [PATCH] Exchange Sanity to Coherence --- README.md | 4 ++-- pyproject.toml | 10 +++++----- ...hexagonal_config.py => hexagonal_project_config.py} | 0 src/hexagonal/infrastructure/cli.py | 6 +++--- ...y_usecase.py => check_project_coherence_usecase.py} | 2 +- tests/integration_tests/infrastructure/test_cli.py | 2 +- ...case.py => test_check_project_coherence_usecase.py} | 9 ++++----- 7 files changed, 16 insertions(+), 17 deletions(-) rename src/hexagonal/{sanity_check_hexagonal_config.py => hexagonal_project_config.py} (100%) rename src/hexagonal/use_cases/{check_project_sanity_usecase.py => check_project_coherence_usecase.py} (98%) rename tests/integration_tests/use_cases/{test_check_project_sanity_usecase.py => test_check_project_coherence_usecase.py} (85%) diff --git a/README.md b/README.md index 253c499..956a1aa 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Hexagonal Sanity Check +# Hexagonal Coherence Check This project checks if the dependency flow between the layers of the Hexagonal architecture defined for this project was respected. ### How to install -It can be easily installed via pip: `pip install hexagonal-sanity-check` +It can be easily installed via pip: `pip install hexagonal-py` ### How to configure your project diff --git a/pyproject.toml b/pyproject.toml index c60adeb..499da8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] -name = "hexagonal-sanity-check" -version = "0.0.21" -description = """Hexagonal Sanity Check""" +name = "hexagonal-coherence-check" +version = "0.0.22" +description = """Hexagonal Coherence Check""" readme = 'README.md' authors = ["rfrezino "] packages = [{ include = "hexagonal", from = "src"}] -keywords = ["hexagonal architecture", "onion architecture", "enforce rules"] -exclude = ["src/hexagonal/sanity_check_hexagonal_config.py"] +keywords = ["hexagonal architecture", "onion architecture", "enforce rules", "coherence check"] +exclude = ["src/hexagonal/hexagonal_project_config.py"] [tool.poetry.dependencies] python = "^3.7" diff --git a/src/hexagonal/sanity_check_hexagonal_config.py b/src/hexagonal/hexagonal_project_config.py similarity index 100% rename from src/hexagonal/sanity_check_hexagonal_config.py rename to src/hexagonal/hexagonal_project_config.py diff --git a/src/hexagonal/infrastructure/cli.py b/src/hexagonal/infrastructure/cli.py index b5f8b08..f94cc46 100644 --- a/src/hexagonal/infrastructure/cli.py +++ b/src/hexagonal/infrastructure/cli.py @@ -7,11 +7,11 @@ from hexagonal.domain.hexagonal_error import HexagonalError from hexagonal.hexagonal_config import hexagonal_config -from hexagonal.use_cases.check_project_sanity_usecase import CheckProjectSanityUseCase, HexagonalCheckResponse +from hexagonal.use_cases.check_project_coherence_usecase import CheckProjectCoherenceUseCase, HexagonalCheckResponse from hexagonal.use_cases.generate_diagram_usecase import GenerateDiagramUseCase -@click.group(help='Options for Hexagonal Sanity Check') +@click.group(help='Options for Hexagonal Coherence Check') def cli(): pass @@ -43,7 +43,7 @@ def _build_response_message() -> str: try: _process_cli_arguments(source_path=source_path, hexagonal_config_file=hexagonal_config_file) - checker = CheckProjectSanityUseCase(hexagonal_config=hexagonal_config, source_folder=source_path) + checker = CheckProjectCoherenceUseCase(hexagonal_config=hexagonal_config, source_folder=source_path) response = checker.check() _print_check_response(response) except Exception as error: diff --git a/src/hexagonal/use_cases/check_project_sanity_usecase.py b/src/hexagonal/use_cases/check_project_coherence_usecase.py similarity index 98% rename from src/hexagonal/use_cases/check_project_sanity_usecase.py rename to src/hexagonal/use_cases/check_project_coherence_usecase.py index 5338c28..4d1a215 100644 --- a/src/hexagonal/use_cases/check_project_sanity_usecase.py +++ b/src/hexagonal/use_cases/check_project_coherence_usecase.py @@ -18,7 +18,7 @@ class HexagonalCheckResponse: hexagonal_project: HexagonalProject -class CheckProjectSanityUseCase: +class CheckProjectCoherenceUseCase: _source_folder_full_path: str _source_folder: str _hexagonal_config: HexagonalConfig diff --git a/tests/integration_tests/infrastructure/test_cli.py b/tests/integration_tests/infrastructure/test_cli.py index afea14c..f2eb80c 100644 --- a/tests/integration_tests/infrastructure/test_cli.py +++ b/tests/integration_tests/infrastructure/test_cli.py @@ -12,7 +12,7 @@ def test_cli_bootstrap_should_return_true(self): # This tests check the consistency of this on project runner = CliRunner() result = runner.invoke(check, ['--source_path', get_project_path() + '/src/hexagonal', - '--hexagonal_config_file', 'sanity_check_hexagonal_config.py']) + '--hexagonal_config_file', 'hexagonal_project_config.py']) expected_msg = 'Hexagonal Architecture: Checked a project with 4 hexagonal layers, ' \ '25 python files and found 0 errors.' diff --git a/tests/integration_tests/use_cases/test_check_project_sanity_usecase.py b/tests/integration_tests/use_cases/test_check_project_coherence_usecase.py similarity index 85% rename from tests/integration_tests/use_cases/test_check_project_sanity_usecase.py rename to tests/integration_tests/use_cases/test_check_project_coherence_usecase.py index f2d8cb8..500ad95 100644 --- a/tests/integration_tests/use_cases/test_check_project_sanity_usecase.py +++ b/tests/integration_tests/use_cases/test_check_project_coherence_usecase.py @@ -2,12 +2,11 @@ from hexagonal.domain.hexagonal_layer import HexagonalLayer from hexagonal.hexagonal_config import HexagonalConfig -from hexagonal.services.hexagonal_composition import HexagonalComposition -from hexagonal.use_cases.check_project_sanity_usecase import CheckProjectSanityUseCase +from hexagonal.use_cases.check_project_coherence_usecase import CheckProjectCoherenceUseCase from tests.integration_tests.utils.utils import get_sample_wrong_test_project_path, get_sample_correct_test_project_path -class HexagonalSanityCheckUnitTest(TestCase): +class HexagonalCoherenceCheckUnitTest(TestCase): def test_check_when_project_has_wrong_dependencies_import_return_errors(self): expected_project_full_path = get_sample_wrong_test_project_path() @@ -18,7 +17,7 @@ def test_check_when_project_has_wrong_dependencies_import_return_errors(self): hexagonal_config.add_inner_layer(HexagonalLayer(name='services', directories=['/services'])) hexagonal_config.add_inner_layer(HexagonalLayer(name='domain', directories=['/domain'])) - usecase = CheckProjectSanityUseCase(hexagonal_config=hexagonal_config, + usecase = CheckProjectCoherenceUseCase(hexagonal_config=hexagonal_config, source_folder=expected_project_full_path) response = usecase.check() @@ -41,7 +40,7 @@ def test_check_when_project_has_right_dependencies_import_return_no_errors(self) hexagonal_config.add_inner_layer(HexagonalLayer(name='services', directories=['/services'])) hexagonal_config.add_inner_layer(HexagonalLayer(name='domain', directories=['/domain'])) - usecase = CheckProjectSanityUseCase(hexagonal_config=hexagonal_config, source_folder=expected_project_full_path) + usecase = CheckProjectCoherenceUseCase(hexagonal_config=hexagonal_config, source_folder=expected_project_full_path) response = usecase.check() self.assertEqual(11, len(response.python_files))