From 4351069eee76a885bf11cf98e1e6b1ba40227ff0 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sat, 16 Apr 2022 17:15:38 -0400 Subject: [PATCH] Create Directory On Download (#42) * Make Directory * Remove Broken Test --- cppython/project.py | 6 +++++- tests/unit/test_project.py | 26 ++------------------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/cppython/project.py b/cppython/project.py index 1e7c66e..9d07313 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -139,10 +139,14 @@ def download(self): Download the generator tooling if required """ if self._enabled: - path = self.pyproject.tool.cppython.install_path + base_path = self.pyproject.tool.cppython.install_path for generator in self._generators: + path = base_path / generator.name() + + path.mkdir(parents=True, exist_ok=True) + if not generator.generator_downloaded(path): self._interface.print(f"Downloading the {generator.name()} tool") diff --git a/tests/unit/test_project.py b/tests/unit/test_project.py index 9d3d85f..40bb2ac 100644 --- a/tests/unit/test_project.py +++ b/tests/unit/test_project.py @@ -2,6 +2,8 @@ Test the functions related to the internal interface implementation and the 'Interface' interface itself """ +from pathlib import Path + from cppython_core.schema import Generator, GeneratorData, PyProject from pytest_mock import MockerFixture @@ -31,30 +33,6 @@ def test_construction(self, mocker: MockerFixture): configuration = ProjectConfiguration() Project(configuration, interface_mock, default_pyproject.dict(by_alias=True)) - def test_download(self, mocker: MockerFixture): - """ - TODO - """ - - interface_mock = mocker.MagicMock() - configuration = ProjectConfiguration() - - generator_type = mocker.Mock(spec=Generator) - generator_type.name.return_value = "mock" - generator_type.data_type.return_value = MockGeneratorData - - gather_override = mocker.patch.object(ProjectBuilder, "gather_plugins") - gather_override.return_value = [generator_type] - - project_data = default_pyproject.dict(by_alias=True) - mock_data = MockGeneratorData(check=True) - project_data["tool"]["cppython"]["mock"] = mock_data.dict(by_alias=True) - - project = Project(configuration, interface_mock, project_data) - - # TODO: This does not verify signature correctness - project.download() - class TestBuilder: """