From ad434ea0083e0ad8b0e8666813515fbc94221a46 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 16:22:51 -0500 Subject: [PATCH 01/22] Conditional Running --- cppython/plugins/test/data.py | 4 ++-- cppython/project.py | 15 ++++++++++----- cppython/schema.py | 9 +++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/cppython/plugins/test/data.py b/cppython/plugins/test/data.py index 76a30e7..df49c7b 100644 --- a/cppython/plugins/test/data.py +++ b/cppython/plugins/test/data.py @@ -10,6 +10,6 @@ # CMake is a default plugin # TODO: Provide dynamic default -default_cppython_data = CPPythonData(generator="cmake", target=TargetEnum.EXE, install_path=Path()) +default_cppython_data = CPPythonData(**{"generator": "cmake", "target": TargetEnum.EXE, "install-path": Path()}) -default_pyproject = PyProject(pep_621=default_pep621, cppython_data=default_cppython_data) +default_pyproject = PyProject(project=default_pep621, cppython=default_cppython_data) diff --git a/cppython/project.py b/cppython/project.py index 20d195e..5300fba 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -16,6 +16,8 @@ class Project(API): def __init__(self, interface: Interface, pyproject: PyProject) -> None: + self.enabled = pyproject.cppython != None + self._interface = interface PluginType = TypeVar("PluginType", bound=Type[Plugin]) @@ -35,10 +37,10 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) return None - plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython_data.generator) + plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython.generator) if plugin_type is None: - raise ConfigError(f"No generator plugin with the name '{pyproject.cppython_data.generator}' was found.") + raise ConfigError(f"No generator plugin with the name '{pyproject.cppython.generator}' was found.") generator_data = interface.read_generator_data(plugin_type.data_type()) self._generator = plugin_type(pyproject, generator_data) @@ -47,10 +49,13 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) # API Contract def install(self) -> None: - self._generator.install() + if self.enabled: + self._generator.install() def update(self) -> None: - self._generator.update() + if self.enabled: + self._generator.update() def build(self) -> None: - self._generator.build() + if self.enabled: + self._generator.build() diff --git a/cppython/schema.py b/cppython/schema.py index ba363af..aea2566 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -5,9 +5,10 @@ from abc import ABC, abstractmethod from enum import Enum from pathlib import Path -from typing import Type, TypeVar +from typing import Optional, Type, TypeVar from pydantic import BaseModel +from pydantic.fields import Field class TargetEnum(Enum): @@ -40,7 +41,7 @@ class CPPythonData(BaseModel): generator: str target: TargetEnum dependencies: dict[str, str] = {} - install_path: Path + install_path: Path = Field(alias="install-path") class PyProject(BaseModel): @@ -48,8 +49,8 @@ class PyProject(BaseModel): pyproject.toml schema """ - pep_621: PEP621 - cppython_data: CPPythonData + project: PEP621 + cppython: Optional[CPPythonData] class API(ABC): From a8765b4cb53fd2745dc0936a3e047a0dfd7ef2c4 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 16:25:22 -0500 Subject: [PATCH 02/22] Install Generator --- cppython/project.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cppython/project.py b/cppython/project.py index 5300fba..f05418f 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -50,6 +50,7 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) def install(self) -> None: if self.enabled: + self._generator.install_generator() self._generator.install() def update(self) -> None: From 426b6f735dbdd47c0a578a138242dac1eaf5943c Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 17:17:16 -0500 Subject: [PATCH 03/22] Download and Print --- cppython/plugins/generator/cmake.py | 6 ++++-- cppython/plugins/interface/console.py | 4 +++- cppython/project.py | 11 +++++++++-- cppython/schema.py | 19 ++++++++++++++++--- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py index ff859ce..83e266a 100644 --- a/cppython/plugins/generator/cmake.py +++ b/cppython/plugins/generator/cmake.py @@ -34,12 +34,14 @@ def data_type() -> Type[GeneratorData]: """ return CMakeData - def install_generator(self) -> bool: + def downloaded(self) -> bool: + return True + + def download(self) -> None: """ Installs the external tooling required by the generator if necessary Returns whether anything was installed or not """ - return False def install(self) -> None: raise NotImplementedError() diff --git a/cppython/plugins/interface/console.py b/cppython/plugins/interface/console.py index a2e6219..3137a8d 100644 --- a/cppython/plugins/interface/console.py +++ b/cppython/plugins/interface/console.py @@ -109,4 +109,6 @@ def write_pyproject(self) -> None: """ Write output """ - pass + + def print(self, string: str) -> None: + click.echo(string) diff --git a/cppython/project.py b/cppython/project.py index f05418f..2f6e769 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -44,13 +44,20 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) generator_data = interface.read_generator_data(plugin_type.data_type()) self._generator = plugin_type(pyproject, generator_data) - self._generator.install_generator() + + def download(self): + """ + Download the generator tooling if required + """ + if not self._generator.downloaded(): + + self._generator.download() # API Contract def install(self) -> None: if self.enabled: - self._generator.install_generator() + self.download() self._generator.install() def update(self) -> None: diff --git a/cppython/schema.py b/cppython/schema.py index aea2566..9b0c8eb 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -132,6 +132,13 @@ def write_pyproject(self) -> None: """ raise NotImplementedError() + @abstractmethod + def print(self, string: str) -> None: + """ + Prints the given string into the Interface IO + """ + raise NotImplementedError() + class Generator(Plugin, API): """ @@ -166,9 +173,15 @@ def data_type() -> Type[GeneratorData]: raise NotImplementedError() @abstractmethod - def install_generator(self) -> bool: + def downloaded(self) -> bool: + """ + Returns whether the generator needs to be downloaded + """ + raise NotImplementedError() + + @abstractmethod + def download(self) -> None: """ - Installs the external tooling required by the generator if necessary - Returns whether anything was installed or not + Installs the external tooling required by the generator """ raise NotImplementedError() From 49f99f562956602603755e72d5c083cdcc7eacc7 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 17:17:36 -0500 Subject: [PATCH 04/22] Update data.py --- cppython/plugins/test/data.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cppython/plugins/test/data.py b/cppython/plugins/test/data.py index df49c7b..abdee63 100644 --- a/cppython/plugins/test/data.py +++ b/cppython/plugins/test/data.py @@ -9,7 +9,6 @@ default_pep621 = PEP621(name="test_name", version="1.0") # CMake is a default plugin -# TODO: Provide dynamic default default_cppython_data = CPPythonData(**{"generator": "cmake", "target": TargetEnum.EXE, "install-path": Path()}) default_pyproject = PyProject(project=default_pep621, cppython=default_cppython_data) From d5786764fff45fbe57aac6449a716a21bee9194d Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 17:20:40 -0500 Subject: [PATCH 05/22] Add Download Print --- cppython/project.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cppython/project.py b/cppython/project.py index 2f6e769..92284b0 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -50,8 +50,11 @@ def download(self): Download the generator tooling if required """ if not self._generator.downloaded(): + self._interface.print(f"Downloading the {self._generator.name()} tool") + # TODO: Make async with progress bar self._generator.download() + self._interface.print("Download complete") # API Contract From 1001334a9ac00314315c7b6b1f5ac4005a3892a4 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 6 Mar 2022 17:39:08 -0500 Subject: [PATCH 06/22] Early out construction --- cppython/project.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cppython/project.py b/cppython/project.py index 92284b0..6bd8d7d 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -16,7 +16,10 @@ class Project(API): def __init__(self, interface: Interface, pyproject: PyProject) -> None: - self.enabled = pyproject.cppython != None + self.enabled = pyproject.cppython is not None + + if not self.enabled: + return self._interface = interface From 7fd7824a93d899cdb43ef798a757ceb725370385 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Mon, 7 Mar 2022 21:31:51 -0500 Subject: [PATCH 07/22] Remove Abstract Requirement From Generator --- .github/workflows/{release.yml => python-publish.yml} | 0 cppython/plugins/generator/cmake.py | 4 +++- cppython/schema.py | 4 ---- 3 files changed, 3 insertions(+), 5 deletions(-) rename .github/workflows/{release.yml => python-publish.yml} (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/python-publish.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/python-publish.yml diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py index 83e266a..b7300ce 100644 --- a/cppython/plugins/generator/cmake.py +++ b/cppython/plugins/generator/cmake.py @@ -18,7 +18,9 @@ class CMakeGenerator(Generator): """ def __init__(self, pyproject: PyProject, cmake_data: CMakeData) -> None: - super().__init__(pyproject, cmake_data) + """ + TODO + """ @staticmethod def name() -> str: diff --git a/cppython/schema.py b/cppython/schema.py index 9b0c8eb..388800a 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -145,10 +145,6 @@ class Generator(Plugin, API): Abstract type to be inherited by CPPython Generator plugins """ - @abstractmethod - def __init__(self, pyproject: PyProject, generator_data: GeneratorData) -> None: - super().__init__() - @staticmethod def plugin_group() -> str: """ From 6287c1cd902a8449af34cb3f768fc074fd0d3061 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Wed, 9 Mar 2022 06:31:40 -0500 Subject: [PATCH 08/22] Update Metadata --- pyproject.toml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index de30104..a8d599a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,17 +2,13 @@ description = " A Python package manager agnostic plugin integrating a transparent Conan and CMake workflow." name = "cppython" -license = "MIT" +license-expression = "MIT" authors = [ - "Synodic Software", + {name = "Synodic Software", email = "contact@synodic.software"}, ] - readme = "README.md" -homepage = "https://github.com/Synodic-Software/CPPython" -repository = "https://github.com/Synodic-Software/CPPython" - dynamic = ["version"] requires-python = ">=3.10" @@ -25,6 +21,13 @@ dependencies = [ "pytest>=7.0.0", # Required for testing injection ] +[project.license-files] +paths = ["LICENSE.md"] + +[project.urls] +homepage = "https://github.com/Synodic-Software/CPPython" +repository = "https://github.com/Synodic-Software/CPPython" + [tool.pdm] version = {use_scm = true} From 45deb1084756099eebf43a0536aab9a2d912330f Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 10 Mar 2022 05:51:28 -0500 Subject: [PATCH 09/22] Readd Abstract Init --- cppython/schema.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cppython/schema.py b/cppython/schema.py index 388800a..bf2c758 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -145,6 +145,12 @@ class Generator(Plugin, API): Abstract type to be inherited by CPPython Generator plugins """ + @abstractmethod + def __init__(self, pyproject: PyProject, generator_data: GeneratorData) -> None: + """ + TODO + """ + @staticmethod def plugin_group() -> str: """ From 6dd8e326ce9cf5eca675d188147e42729c45b35a Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 10 Mar 2022 06:35:41 -0500 Subject: [PATCH 10/22] Add Tooling Update Requirement --- cppython/plugins/generator/cmake.py | 16 ++++++++++------ cppython/schema.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py index b7300ce..3f708c9 100644 --- a/cppython/plugins/generator/cmake.py +++ b/cppython/plugins/generator/cmake.py @@ -18,9 +18,7 @@ class CMakeGenerator(Generator): """ def __init__(self, pyproject: PyProject, cmake_data: CMakeData) -> None: - """ - TODO - """ + self.data = cmake_data @staticmethod def name() -> str: @@ -36,13 +34,19 @@ def data_type() -> Type[GeneratorData]: """ return CMakeData - def downloaded(self) -> bool: + def generator_downloaded(self) -> bool: + + # CMake tooling is a part of the python package tooling return True - def download(self) -> None: + def download_generator(self) -> None: """ Installs the external tooling required by the generator if necessary - Returns whether anything was installed or not + """ + + def update_generator(self) -> None: + """ + Update the tooling required by the generator """ def install(self) -> None: diff --git a/cppython/schema.py b/cppython/schema.py index bf2c758..6c777bc 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -148,7 +148,7 @@ class Generator(Plugin, API): @abstractmethod def __init__(self, pyproject: PyProject, generator_data: GeneratorData) -> None: """ - TODO + Allows CPPython to pass the relevant data to constructed Generator plugin """ @staticmethod @@ -175,15 +175,22 @@ def data_type() -> Type[GeneratorData]: raise NotImplementedError() @abstractmethod - def downloaded(self) -> bool: + def generator_downloaded(self) -> bool: """ Returns whether the generator needs to be downloaded """ raise NotImplementedError() @abstractmethod - def download(self) -> None: + def download_generator(self) -> None: """ Installs the external tooling required by the generator """ raise NotImplementedError() + + @abstractmethod + def update_generator(self) -> None: + """ + Update the tooling required by the generator + """ + raise NotImplementedError() From 2a0588c66a02c2944d4fca8a44d7ab3944bf762f Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 10 Mar 2022 15:20:56 -0500 Subject: [PATCH 11/22] Move Data --- cppython/{plugins/test => }/data.py | 0 cppython/plugins/test/pytest.py | 2 +- tests/integration/test_generator.py | 2 +- tests/unit/test_generator.py | 2 +- tests/unit/test_interface.py | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename cppython/{plugins/test => }/data.py (100%) diff --git a/cppython/plugins/test/data.py b/cppython/data.py similarity index 100% rename from cppython/plugins/test/data.py rename to cppython/data.py diff --git a/cppython/plugins/test/pytest.py b/cppython/plugins/test/pytest.py index 0a120f8..5fda21b 100644 --- a/cppython/plugins/test/pytest.py +++ b/cppython/plugins/test/pytest.py @@ -7,7 +7,7 @@ import pytest -from cppython.plugins.test.data import default_pyproject +from cppython.data import default_pyproject from cppython.project import Project from cppython.schema import Generator, Interface diff --git a/tests/integration/test_generator.py b/tests/integration/test_generator.py index d3ccd5f..23886f5 100644 --- a/tests/integration/test_generator.py +++ b/tests/integration/test_generator.py @@ -4,8 +4,8 @@ import pytest +from cppython.data import default_pyproject from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.data import default_pyproject from cppython.plugins.test.pytest import GeneratorIntegrationTests diff --git a/tests/unit/test_generator.py b/tests/unit/test_generator.py index d8871fb..3f433fa 100644 --- a/tests/unit/test_generator.py +++ b/tests/unit/test_generator.py @@ -4,8 +4,8 @@ import pytest +from cppython.data import default_pyproject from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.data import default_pyproject from cppython.plugins.test.pytest import GeneratorUnitTests diff --git a/tests/unit/test_interface.py b/tests/unit/test_interface.py index d8fa1d8..f748154 100644 --- a/tests/unit/test_interface.py +++ b/tests/unit/test_interface.py @@ -6,8 +6,8 @@ from click.testing import CliRunner from pytest_mock.plugin import MockerFixture +from cppython.data import default_pyproject from cppython.plugins.interface.console import Config, ConsoleInterface, cli -from cppython.plugins.test.data import default_pyproject from cppython.plugins.test.pytest import InterfaceUnitTests from cppython.schema import API From e63800786928bc7bd8e074a02127148479af8207 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 10 Mar 2022 16:48:19 -0500 Subject: [PATCH 12/22] Proper Data Labelling --- cppython/data.py | 6 +++--- cppython/plugins/generator/cmake.py | 2 ++ cppython/project.py | 10 +++++----- cppython/schema.py | 10 +++++++++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/cppython/data.py b/cppython/data.py index abdee63..de8078e 100644 --- a/cppython/data.py +++ b/cppython/data.py @@ -4,11 +4,11 @@ from pathlib import Path -from cppython.schema import PEP621, CPPythonData, PyProject, TargetEnum +from cppython.schema import PEP621, CPPythonData, PyProject, TargetEnum, ToolData default_pep621 = PEP621(name="test_name", version="1.0") # CMake is a default plugin default_cppython_data = CPPythonData(**{"generator": "cmake", "target": TargetEnum.EXE, "install-path": Path()}) - -default_pyproject = PyProject(project=default_pep621, cppython=default_cppython_data) +default_tool_data = ToolData(**{"cppython": default_cppython_data}) +default_pyproject = PyProject(**{"project": default_pep621, "tool": default_tool_data}) diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py index 3f708c9..1a3c01a 100644 --- a/cppython/plugins/generator/cmake.py +++ b/cppython/plugins/generator/cmake.py @@ -20,6 +20,8 @@ class CMakeGenerator(Generator): def __init__(self, pyproject: PyProject, cmake_data: CMakeData) -> None: self.data = cmake_data + super().__init__(pyproject, cmake_data) + @staticmethod def name() -> str: """ diff --git a/cppython/project.py b/cppython/project.py index 6bd8d7d..2384fca 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -16,7 +16,7 @@ class Project(API): def __init__(self, interface: Interface, pyproject: PyProject) -> None: - self.enabled = pyproject.cppython is not None + self.enabled = pyproject.tool is not None and pyproject.tool.cppython is not None if not self.enabled: return @@ -40,10 +40,10 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) return None - plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.cppython.generator) + plugin_type = find_plugin_type(Generator, lambda name: name == pyproject.tool.cppython.generator) if plugin_type is None: - raise ConfigError(f"No generator plugin with the name '{pyproject.cppython.generator}' was found.") + raise ConfigError(f"No generator plugin with the name '{pyproject.tool.cppython.generator}' was found.") generator_data = interface.read_generator_data(plugin_type.data_type()) self._generator = plugin_type(pyproject, generator_data) @@ -52,11 +52,11 @@ def download(self): """ Download the generator tooling if required """ - if not self._generator.downloaded(): + if not self._generator.generator_downloaded(): self._interface.print(f"Downloading the {self._generator.name()} tool") # TODO: Make async with progress bar - self._generator.download() + self._generator.download_generator() self._interface.print("Download complete") # API Contract diff --git a/cppython/schema.py b/cppython/schema.py index 6c777bc..e4fe9a3 100644 --- a/cppython/schema.py +++ b/cppython/schema.py @@ -44,13 +44,21 @@ class CPPythonData(BaseModel): install_path: Path = Field(alias="install-path") +class ToolData(BaseModel): + """ + TODO + """ + + cppython: Optional[CPPythonData] + + class PyProject(BaseModel): """ pyproject.toml schema """ project: PEP621 - cppython: Optional[CPPythonData] + tool: Optional[ToolData] class API(ABC): From bee420f4f22c20f39b37452ad2761c0c3404dd50 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sat, 12 Mar 2022 11:37:45 -0500 Subject: [PATCH 13/22] Remove Core + Test --- cppython/exceptions.py | 24 ---- cppython/plugins/test/__init__.py | 1 - cppython/plugins/test/pytest.py | 97 -------------- cppython/schema.py | 204 ------------------------------ pyproject.toml | 5 - 5 files changed, 331 deletions(-) delete mode 100644 cppython/exceptions.py delete mode 100644 cppython/plugins/test/__init__.py delete mode 100644 cppython/plugins/test/pytest.py delete mode 100644 cppython/schema.py diff --git a/cppython/exceptions.py b/cppython/exceptions.py deleted file mode 100644 index c9d3102..0000000 --- a/cppython/exceptions.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Custom exceptions used by CPPython -""" - - -class ConfigError(Exception): - """ - Raised when there is a configuration error - """ - - def __init__(self, error: str) -> None: - self._error = error - - super().__init__(error) - - @property - def error(self) -> str: - """ - Returns the underlying error - - Returns: - str -- The underlying error - """ - return self._error diff --git a/cppython/plugins/test/__init__.py b/cppython/plugins/test/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/test/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/plugins/test/pytest.py b/cppython/plugins/test/pytest.py deleted file mode 100644 index 5fda21b..0000000 --- a/cppython/plugins/test/pytest.py +++ /dev/null @@ -1,97 +0,0 @@ -""" -Helper fixtures and plugin definitions for pytest -TODO: Should by a pytest plugin, removing the need for this module in production code. -""" -from abc import ABC -from importlib.metadata import entry_points - -import pytest - -from cppython.data import default_pyproject -from cppython.project import Project -from cppython.schema import Generator, Interface - - -class GeneratorTests(ABC): - """ - Shared functionality between the different Generator testing categories - """ - - @pytest.fixture(name="generator") - def fixture_generator(self) -> Generator: - """ - A hook allowing implementations to override the fixture with a parameterization - @pytest.mark.parametrize("generator", [CustomGenerator]) - """ - raise NotImplementedError - - -class GeneratorIntegrationTests(GeneratorTests): - """ - Base class for all generator integration tests that test plugin agnostic behavior - """ - - def test_plugin_registration(self, generator: Generator): - """ - Test the registration with setuptools entry_points - """ - plugin_entries = entry_points(group=f"cppython.{generator.plugin_group()}") - assert len(plugin_entries) > 0 - - -class GeneratorUnitTests(GeneratorTests): - """ - Custom implementations of the Generator class should inherit from this class for its tests. - Base class for all generator unit tests that test plugin agnostic behavior - """ - - def test_name(self, generator: Generator): - """ - Test name restrictions - TODO: This should be a pydantic schema - """ - name = generator.name() - - assert name != "" - - def test_data_type(self, generator: Generator): - """ - Test data_type restrictions - TODO: This should be a pydantic schema - """ - data_type = generator.data_type() - - assert data_type != "" - - -class InterfaceTests(ABC): - """ - Shared functionality between the different Interface testing categories - """ - - @pytest.fixture(name="interface") - def fixture_interface(self) -> Interface: - """ - A hook allowing implementations to override the fixture with a parameterization - @pytest.mark.parametrize("interface", [CustomInterface]) - """ - raise NotImplementedError - - -class InterfaceIntegrationTests(InterfaceTests): - """ - Base class for all interface integration tests that test plugin agnostic behavior - """ - - def test_project(self, interface: Interface): - """ - Test that the project can be constructed from the given interface - """ - Project(interface, default_pyproject) - - -class InterfaceUnitTests(InterfaceTests): - """ - Custom implementations of the Interface class should inherit from this class for its tests. - Base class for all interface unit tests that test plugin agnostic behavior - """ diff --git a/cppython/schema.py b/cppython/schema.py deleted file mode 100644 index e4fe9a3..0000000 --- a/cppython/schema.py +++ /dev/null @@ -1,204 +0,0 @@ -""" -Data types for CPPython that encapsulate the requirements between the plugins and the core library -""" - -from abc import ABC, abstractmethod -from enum import Enum -from pathlib import Path -from typing import Optional, Type, TypeVar - -from pydantic import BaseModel -from pydantic.fields import Field - - -class TargetEnum(Enum): - """ - The C++ build target type - """ - - EXE = "executable" - STATIC = "static" - SHARED = "shared" - - -class PEP621(BaseModel): - """ - PEP 621 conforming data - The entirety of PEP 621 is not relevant for interface plugins - Schema: https://www.python.org/dev/peps/pep-0621/ - """ - - name: str - version: str - description: str = "" - - -class CPPythonData(BaseModel): - """ - Data required by the tool - """ - - generator: str - target: TargetEnum - dependencies: dict[str, str] = {} - install_path: Path = Field(alias="install-path") - - -class ToolData(BaseModel): - """ - TODO - """ - - cppython: Optional[CPPythonData] - - -class PyProject(BaseModel): - """ - pyproject.toml schema - """ - - project: PEP621 - tool: Optional[ToolData] - - -class API(ABC): - """ - API - """ - - @abstractmethod - def install(self) -> None: - """ - Called when dependencies need to be installed from a lock file. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - @abstractmethod - def update(self) -> None: - """ - Called when dependencies need to be updated and written to the lock file. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - @abstractmethod - def build(self) -> None: - """ - Called when the C++ target needs to be produced. - - Raises: - NotImplementedError: [description] - """ - raise NotImplementedError() - - -class Plugin(ABC): - """ - Abstract plugin type - """ - - @staticmethod - @abstractmethod - def plugin_group() -> str: - """ - The plugin group name as used by 'setuptools' - """ - raise NotImplementedError() - - -class GeneratorData(BaseModel): - """ - Base class for the configuration data that will be read by the interface and given to the generator - """ - - -GeneratorDataType = TypeVar("GeneratorDataType", bound=GeneratorData) - - -class Interface: - """ - Abstract type to be inherited by CPPython interfaces - """ - - @abstractmethod - def read_generator_data(self, generator_data_type: Type[GeneratorDataType]) -> GeneratorDataType: - """ - Dynamic pyproject.toml data that is determined by the generator plugin requested by [tool.cppython.generator] - The Schema defined by 'generator_data_type' must be filled by the [tool.cppython.{generator_value}] slot. - """ - raise NotImplementedError() - - @abstractmethod - def write_pyproject(self) -> None: - """ - Called when CPPython requires the interface to write out pyproject.toml changes - """ - raise NotImplementedError() - - @abstractmethod - def print(self, string: str) -> None: - """ - Prints the given string into the Interface IO - """ - raise NotImplementedError() - - -class Generator(Plugin, API): - """ - Abstract type to be inherited by CPPython Generator plugins - """ - - @abstractmethod - def __init__(self, pyproject: PyProject, generator_data: GeneratorData) -> None: - """ - Allows CPPython to pass the relevant data to constructed Generator plugin - """ - - @staticmethod - def plugin_group() -> str: - """ - The plugin group name as used by 'setuptools' - """ - return "generator_plugins" - - @staticmethod - @abstractmethod - def name() -> str: - """ - The string that is matched with the [tool.cppython.generator] string - """ - raise NotImplementedError() - - @staticmethod - @abstractmethod - def data_type() -> Type[GeneratorData]: - """ - Returns the pydantic type to cast the generator configuration data to - """ - raise NotImplementedError() - - @abstractmethod - def generator_downloaded(self) -> bool: - """ - Returns whether the generator needs to be downloaded - """ - raise NotImplementedError() - - @abstractmethod - def download_generator(self) -> None: - """ - Installs the external tooling required by the generator - """ - raise NotImplementedError() - - @abstractmethod - def update_generator(self) -> None: - """ - Update the tooling required by the generator - """ - raise NotImplementedError() diff --git a/pyproject.toml b/pyproject.toml index a8d599a..6a03b53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,10 +49,6 @@ cppython = "cppython.plugins.interface.console:cli" [project.entry-points."cppython.generator_plugins"] cmake = "cppython.plugins.generator.cmake:CMakeGenerator" -# Pytest plugins -[tool.entry-points.pytest11] -pytest_cppython = "cppython.plugins.test.pytest" - [tool.pytest.ini_options] testpaths = [ "tests", @@ -67,7 +63,6 @@ profile = "black" [tool.pylint.messages_control] disable = "C0330, C0326" -extension-pkg-whitelist = "pydantic" [tool.pylint.format] max-line-length = "120" From 2bcc97f52f9c71c57b0c55281a5aecaed6bebab2 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 13 Mar 2022 21:39:05 -0400 Subject: [PATCH 14/22] Update Tests --- cppython/{plugins/interface => }/console.py | 5 +- cppython/data.py | 2 +- cppython/plugins/generator/__init__.py | 1 - cppython/plugins/generator/cmake.py | 61 ----------------- cppython/plugins/interface/__init__.py | 1 - cppython/project.py | 4 +- pdm.lock | 74 ++++++++++++++------- pyproject.toml | 14 ++-- tests/integration/test_generator.py | 26 -------- tests/integration/test_interface.py | 4 +- tests/unit/test_generator.py | 26 -------- tests/unit/test_interface.py | 8 +-- 12 files changed, 69 insertions(+), 157 deletions(-) rename cppython/{plugins/interface => }/console.py (95%) delete mode 100644 cppython/plugins/generator/__init__.py delete mode 100644 cppython/plugins/generator/cmake.py delete mode 100644 cppython/plugins/interface/__init__.py delete mode 100644 tests/integration/test_generator.py delete mode 100644 tests/unit/test_generator.py diff --git a/cppython/plugins/interface/console.py b/cppython/console.py similarity index 95% rename from cppython/plugins/interface/console.py rename to cppython/console.py index 3137a8d..b3699d7 100644 --- a/cppython/plugins/interface/console.py +++ b/cppython/console.py @@ -7,9 +7,9 @@ import click import tomlkit +from cppython_core.schema import GeneratorDataType, Interface, PyProject from cppython.project import Project -from cppython.schema import GeneratorDataType, Interface, PyProject def _create_pyproject(): @@ -111,4 +111,7 @@ def write_pyproject(self) -> None: """ def print(self, string: str) -> None: + """ + TODO + """ click.echo(string) diff --git a/cppython/data.py b/cppython/data.py index de8078e..61551b9 100644 --- a/cppython/data.py +++ b/cppython/data.py @@ -4,7 +4,7 @@ from pathlib import Path -from cppython.schema import PEP621, CPPythonData, PyProject, TargetEnum, ToolData +from cppython_core.schema import PEP621, CPPythonData, PyProject, TargetEnum, ToolData default_pep621 = PEP621(name="test_name", version="1.0") diff --git a/cppython/plugins/generator/__init__.py b/cppython/plugins/generator/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/generator/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/plugins/generator/cmake.py b/cppython/plugins/generator/cmake.py deleted file mode 100644 index 1a3c01a..0000000 --- a/cppython/plugins/generator/cmake.py +++ /dev/null @@ -1,61 +0,0 @@ -""" -The default generator implementation for CPPython -""" -from typing import Type - -from cppython.schema import Generator, GeneratorData, PyProject - - -class CMakeData(GeneratorData): - """ - The data schema required for the CMake tooling - """ - - -class CMakeGenerator(Generator): - """ - A CPPython generator implementing a CMake backend - """ - - def __init__(self, pyproject: PyProject, cmake_data: CMakeData) -> None: - self.data = cmake_data - - super().__init__(pyproject, cmake_data) - - @staticmethod - def name() -> str: - """ - The name of the generator - """ - return "cmake" - - @staticmethod - def data_type() -> Type[GeneratorData]: - """ - Returns the pydantic type to cast the generator configuration data to - """ - return CMakeData - - def generator_downloaded(self) -> bool: - - # CMake tooling is a part of the python package tooling - return True - - def download_generator(self) -> None: - """ - Installs the external tooling required by the generator if necessary - """ - - def update_generator(self) -> None: - """ - Update the tooling required by the generator - """ - - def install(self) -> None: - raise NotImplementedError() - - def update(self) -> None: - raise NotImplementedError() - - def build(self) -> None: - raise NotImplementedError() diff --git a/cppython/plugins/interface/__init__.py b/cppython/plugins/interface/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/interface/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cppython/project.py b/cppython/project.py index 2384fca..0a3a076 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -5,8 +5,8 @@ from importlib import metadata from typing import Callable, Optional, Type, TypeVar -from cppython.exceptions import ConfigError -from cppython.schema import API, Generator, Interface, Plugin, PyProject +from cppython_core.exceptions import ConfigError +from cppython_core.schema import API, Generator, Interface, Plugin, PyProject class Project(API): diff --git a/pdm.lock b/pdm.lock index d4bd678..8f258a8 100644 --- a/pdm.lock +++ b/pdm.lock @@ -45,7 +45,7 @@ dependencies = [ [[package]] name = "cmake" -version = "3.22.2" +version = "3.22.3" summary = "CMake is an open-source, cross-platform family of tools designed to build, test and package software" [[package]] @@ -71,6 +71,15 @@ dependencies = [ "tomli", ] +[[package]] +name = "cppython-core" +version = "0.1.0" +requires_python = ">=3.10" +summary = "Data definitions for CPPython" +dependencies = [ + "pydantic>=1.9", +] + [[package]] name = "iniconfig" version = "1.1.1" @@ -161,8 +170,8 @@ summary = "Python parsing module" [[package]] name = "pytest" -version = "7.0.1" -requires_python = ">=3.6" +version = "7.1.0" +requires_python = ">=3.7" summary = "pytest: simple powerful testing with Python" dependencies = [ "atomicwrites>=1.0; sys_platform == \"win32\"", @@ -185,6 +194,15 @@ dependencies = [ "pytest>=4.6", ] +[[package]] +name = "pytest-cppython" +version = "0.1.0" +requires_python = ">=3.10" +summary = "A pytest plugin that imports CPPython testing types" +dependencies = [ + "cppython-core>=0.1.0", +] + [[package]] name = "pytest-mock" version = "3.7.0" @@ -232,7 +250,7 @@ summary = "Module for decorators, wrappers and monkey patching." [metadata] lock_version = "3.1" -content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f7544cfc" +content_hash = "sha256:66626e32ae603a3def926a3b86656a48b98b2e4016a4646e24cbedde657d3f71" [metadata.files] "astroid 2.9.3" = [ @@ -276,23 +294,23 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"}, {file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"}, ] -"cmake 3.22.2" = [ - {file = "cmake-3.22.2-py2.py3-none-macosx_10_9_universal2.macosx_10_9_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:7bc1c50c9131105b4892528183475d3fc564f3d611f0fe2f1b1bd184f7de1fd4"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ccb57bf773fdc0d3d299da387f7d46f38b452608fdc3100aa294dbb25d216515"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0801156be44344de6b1427ee8e845850d113868001c4c5bd415caf8d44328b8f"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:43b820c4b880e28c10ff78ea0189deed77d77ddc166bb3fd807fa848a2822a25"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:026edb77648e9d84e2f446534a964513cf5ea82f226996bbe6dc480fb8048cf9"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6aff4053fb344dc3d89a3ebd4ef66dd6ba0c8bf0130a2fd3fb8c65baf7316518"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:9bc25b9c8be9507f4fc2004931f0d2f680eeae7c00f6d21aa168839a8aee7432"}, - {file = "cmake-3.22.2-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e01697d8beefd3cb2224aa70139858b6f515fc74348447fe97ddef8b56bf1cb9"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:457e4990e8459cacbe37df6fb1aaf9648d6d08788d8b5f526c46a19d3cd7b700"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:29eecf8285be72db820a60fa4adfc7b1f4c2acc0f3181881d191587ac5272e8c"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:87cce96f5bd40987741718462fa29138d17bb8dbd24cd2a3f0824d2210cac429"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:a642208015f3ffbc95dce55c23058ee7c562d3dece0da398f8d3276f45f5ee34"}, - {file = "cmake-3.22.2-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:7f10f00b863f2c60b585ebb45ae048174d450982c2595f336fcbbd6695a50e19"}, - {file = "cmake-3.22.2-py2.py3-none-win32.whl", hash = "sha256:fd3168e2535ddd0bd9bfff0e4aeb921a61a8351c272654ba71b518da502b9ec2"}, - {file = "cmake-3.22.2-py2.py3-none-win_amd64.whl", hash = "sha256:9f5f563e89a3ee8873a4c48c69d8a32331749da3c3b657d0f0ac74b659e87954"}, - {file = "cmake-3.22.2.tar.gz", hash = "sha256:b5bd5eeb488b13cf64ec963800f3d979eaeb90b4382861b86909df503379e219"}, +"cmake 3.22.3" = [ + {file = "cmake-3.22.3-py2.py3-none-macosx_10_10_universal2.macosx_10_10_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:d387e4062541094d302c80b3beed08cfa4f2ef98454d04f34fd1071c595152d8"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9ff1a89c264a6645d5d222f73efe83ea47abc96d77ae96e3e4eb4580f6f396fc"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3adc8532f5029931e82c9ae6a07b5d866b216b422cedc72074155c80db6e27d7"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c46f0573b0455a234c397fff2f3679e18925eb3da32069cc41f1aab7cd968260"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86c68b283223375ff942bce5b9f2b286fa5ac94b02f848e52fcec2369a407b22"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:452e53346d52241fbebdb9487e88786221c92d4abfa59fb002dc928ada69399c"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fb5fbcb8b45c9f9823a1bffffe8eab673e463b8d36b258856035725e04baf446"}, + {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e615d29c2c26faf7e3876c47bafbab0eefe29683e01bec3a14736e9694bdff73"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:1d6096da730d2d0c8352926b647d0d340fc2ea3a6497dd13cff1c999d68d9d7b"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:d3be0f5256bfe76c81d2db30216c937a7f7cefd251fb63c1cb30c5e0a896bbad"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:d73961a801ea9e2fdda9afa3b9fc84539e368ecec30de1ef54045abfabce4ece"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:45e89f6ff37283ecff912c7fe65dc4bc6dfe2fb78b7747b95272dd7423a3847f"}, + {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:c776ad422f7ce3866497f132af4ba7240cb81d554ee5eb801fd5e2d8c7cd67d6"}, + {file = "cmake-3.22.3-py2.py3-none-win32.whl", hash = "sha256:8d32168fb3153313408befc7b8b5593130bad7d5fe0b8df764bb723b8c710bfc"}, + {file = "cmake-3.22.3-py2.py3-none-win_amd64.whl", hash = "sha256:d8db320fb36560fcf2ca66481009bc1d1f8ed45fd756ce91e4dee97026a0e3a4"}, + {file = "cmake-3.22.3.tar.gz", hash = "sha256:6e1d1991775915dac047af851f2feec7eb35ab4b4610d3e7fd94d93bce8faf58"}, ] "colorama 0.4.4" = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, @@ -341,6 +359,10 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "coverage-6.3.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:18d520c6860515a771708937d2f78f63cc47ab3b80cb78e86573b0a760161faf"}, {file = "coverage-6.3.2.tar.gz", hash = "sha256:03e2a7826086b91ef345ff18742ee9fc47a6839ccd517061ef8fa1976e652ce9"}, ] +"cppython-core 0.1.0" = [ + {file = "cppython_core-0.1.0-py3-none-any.whl", hash = "sha256:97a7c5132eb0fb4c5703d31509e73a746f66576957ebca77b216a50940153d40"}, + {file = "cppython-core-0.1.0.tar.gz", hash = "sha256:2993b038d0d2591be46a8afe6d21ec87c51f634d51d83fed10bd4b5c8ef2df50"}, +] "iniconfig 1.1.1" = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, {file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"}, @@ -461,14 +483,18 @@ content_hash = "sha256:f18a6d6ee6b08697dc4b4ab33ecb41cf6cfe597cbf60877d816cb884f {file = "pyparsing-3.0.7-py3-none-any.whl", hash = "sha256:a6c06a88f252e6c322f65faf8f418b16213b51bdfaece0524c1c1bc30c63c484"}, {file = "pyparsing-3.0.7.tar.gz", hash = "sha256:18ee9022775d270c55187733956460083db60b37d0d0fb357445f3094eed3eea"}, ] -"pytest 7.0.1" = [ - {file = "pytest-7.0.1-py3-none-any.whl", hash = "sha256:9ce3ff477af913ecf6321fe337b93a2c0dcf2a0a1439c43f5452112c1e4280db"}, - {file = "pytest-7.0.1.tar.gz", hash = "sha256:e30905a0c131d3d94b89624a1cc5afec3e0ba2fbdb151867d8e0ebd49850f171"}, +"pytest 7.1.0" = [ + {file = "pytest-7.1.0-py3-none-any.whl", hash = "sha256:b555252a95bbb2a37a97b5ac2eb050c436f7989993565f5e0c9128fcaacadd0e"}, + {file = "pytest-7.1.0.tar.gz", hash = "sha256:f1089d218cfcc63a212c42896f1b7fbf096874d045e1988186861a1a87d27b47"}, ] "pytest-cov 3.0.0" = [ {file = "pytest_cov-3.0.0-py3-none-any.whl", hash = "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6"}, {file = "pytest-cov-3.0.0.tar.gz", hash = "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"}, ] +"pytest-cppython 0.1.0" = [ + {file = "pytest_cppython-0.1.0-py3-none-any.whl", hash = "sha256:f243a909498a1271f0080a65b83b92ec48e92680bcbb28721a528d97f00c218c"}, + {file = "pytest-cppython-0.1.0.tar.gz", hash = "sha256:029e0088969ef8b3217d93ee95f2b3a2dcea607b4bfd16e5ed2427bc3f5da98b"}, +] "pytest-mock 3.7.0" = [ {file = "pytest_mock-3.7.0-py3-none-any.whl", hash = "sha256:6cff27cec936bf81dc5ee87f07132b807bcda51106b5ec4b90a04331cba76231"}, {file = "pytest-mock-3.7.0.tar.gz", hash = "sha256:5112bd92cc9f186ee96e1a92efc84969ea494939c3aead39c50f421c4cc69534"}, diff --git a/pyproject.toml b/pyproject.toml index 6a03b53..2ca02b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,10 +15,10 @@ requires-python = ">=3.10" dependencies = [ "click>=8.0.3", - "cmake>=3.22.2", + "cmake>=3.22.3", "pydantic>=1.9", - "tomlkit>=0.9", - "pytest>=7.0.0", # Required for testing injection + "tomlkit>=0.10.0", + "cppython-core>=0.1.0", ] [project.license-files] @@ -38,16 +38,14 @@ lint = [ "isort>=5.10.1", ] test = [ + "pytest>=7.1.0", "pytest-cov>=3.0.0", "pytest-mock>=3.7.0", + "pytest-cppython>=0.1.0", ] [project.scripts] -cppython = "cppython.plugins.interface.console:cli" - -# CPPython plugins -[project.entry-points."cppython.generator_plugins"] -cmake = "cppython.plugins.generator.cmake:CMakeGenerator" +cppython = "cppython.console:cli" [tool.pytest.ini_options] testpaths = [ diff --git a/tests/integration/test_generator.py b/tests/integration/test_generator.py deleted file mode 100644 index 23886f5..0000000 --- a/tests/integration/test_generator.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Test the integrations related to the internal generator implementation and the 'Generator' interface itself -""" - -import pytest - -from cppython.data import default_pyproject -from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.pytest import GeneratorIntegrationTests - - -class TestCMakeGenerator(GeneratorIntegrationTests): - """ - The tests for our CMake generator - """ - - @pytest.fixture(name="generator") - def fixture_generator(self): - """ - Override of the plugin provided generator fixture. - - Returns: - CMakeGenerator -- The Generator object to use for the CPPython defined tests - """ - cmake_data = CMakeData() - return CMakeGenerator(default_pyproject, cmake_data) diff --git a/tests/integration/test_interface.py b/tests/integration/test_interface.py index c749c2f..b05391b 100644 --- a/tests/integration/test_interface.py +++ b/tests/integration/test_interface.py @@ -3,9 +3,9 @@ """ import pytest +from pytest_cppython.plugin import InterfaceIntegrationTests -from cppython.plugins.interface.console import ConsoleInterface -from cppython.plugins.test.pytest import InterfaceIntegrationTests +from cppython.console import ConsoleInterface class TestCLIInterface(InterfaceIntegrationTests): diff --git a/tests/unit/test_generator.py b/tests/unit/test_generator.py deleted file mode 100644 index 3f433fa..0000000 --- a/tests/unit/test_generator.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -Test the functions related to the internal generator implementation and the 'Generator' interface itself -""" - -import pytest - -from cppython.data import default_pyproject -from cppython.plugins.generator.cmake import CMakeData, CMakeGenerator -from cppython.plugins.test.pytest import GeneratorUnitTests - - -class TestCMakeGenerator(GeneratorUnitTests): - """ - The tests for our CMake generator - """ - - @pytest.fixture(name="generator") - def fixture_generator(self) -> CMakeGenerator: - """ - Override of the plugin provided generator fixture. - - Returns: - CMakeGenerator -- The Generator object to use for the CPPython defined tests - """ - cmake_data = CMakeData() - return CMakeGenerator(default_pyproject, cmake_data) diff --git a/tests/unit/test_interface.py b/tests/unit/test_interface.py index f748154..cf12fab 100644 --- a/tests/unit/test_interface.py +++ b/tests/unit/test_interface.py @@ -4,12 +4,12 @@ import pytest from click.testing import CliRunner +from cppython_core.schema import API +from pytest_cppython.plugin import InterfaceUnitTests from pytest_mock.plugin import MockerFixture +from cppython.console import Config, ConsoleInterface, cli from cppython.data import default_pyproject -from cppython.plugins.interface.console import Config, ConsoleInterface, cli -from cppython.plugins.test.pytest import InterfaceUnitTests -from cppython.schema import API class TestCLIInterface(InterfaceUnitTests): @@ -43,7 +43,7 @@ def test_command(self, command: str, mocker: MockerFixture): mocker.patch("cppython.project.Project.__init__", return_value=None) # Patch the reading of data - mocker.patch("cppython.plugins.interface.console._create_pyproject", return_value=default_pyproject) + mocker.patch("cppython.console._create_pyproject", return_value=default_pyproject) config = Config() From d5b07bd0e596e4409c73e2ebf572851e7b8b5298 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 13 Mar 2022 23:20:23 -0400 Subject: [PATCH 15/22] Rework Early Out Condition --- cppython/project.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cppython/project.py b/cppython/project.py index 0a3a076..78b04ed 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -16,7 +16,15 @@ class Project(API): def __init__(self, interface: Interface, pyproject: PyProject) -> None: - self.enabled = pyproject.tool is not None and pyproject.tool.cppython is not None + self.enabled = False + + if pyproject.tool is None: + return + + if pyproject.tool.cppython is None: + return + + self.enabled = True if not self.enabled: return From 9faf3aae776e127485aceddd22deafbc1c4d5513 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 13 Mar 2022 23:26:09 -0400 Subject: [PATCH 16/22] Fix Condition --- cppython/project.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cppython/project.py b/cppython/project.py index 78b04ed..b6991b5 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -26,9 +26,6 @@ def __init__(self, interface: Interface, pyproject: PyProject) -> None: self.enabled = True - if not self.enabled: - return - self._interface = interface PluginType = TypeVar("PluginType", bound=Type[Plugin]) From 8515f2d7562f15abcab2b89b390e58affb371ba8 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 13 Mar 2022 23:45:19 -0400 Subject: [PATCH 17/22] Remove CMake Requirement --- pdm.lock | 25 +------------------------ pyproject.toml | 1 - 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/pdm.lock b/pdm.lock index 8f258a8..e687a0a 100644 --- a/pdm.lock +++ b/pdm.lock @@ -43,11 +43,6 @@ dependencies = [ "colorama; platform_system == \"Windows\"", ] -[[package]] -name = "cmake" -version = "3.22.3" -summary = "CMake is an open-source, cross-platform family of tools designed to build, test and package software" - [[package]] name = "colorama" version = "0.4.4" @@ -250,7 +245,7 @@ summary = "Module for decorators, wrappers and monkey patching." [metadata] lock_version = "3.1" -content_hash = "sha256:66626e32ae603a3def926a3b86656a48b98b2e4016a4646e24cbedde657d3f71" +content_hash = "sha256:5575b531874fd1b232066c415f5a99fadf1a79121acf890d6182446767ddc8cf" [metadata.files] "astroid 2.9.3" = [ @@ -294,24 +289,6 @@ content_hash = "sha256:66626e32ae603a3def926a3b86656a48b98b2e4016a4646e24cbedde6 {file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"}, {file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"}, ] -"cmake 3.22.3" = [ - {file = "cmake-3.22.3-py2.py3-none-macosx_10_10_universal2.macosx_10_10_x86_64.macosx_11_0_arm64.macosx_11_0_universal2.whl", hash = "sha256:d387e4062541094d302c80b3beed08cfa4f2ef98454d04f34fd1071c595152d8"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9ff1a89c264a6645d5d222f73efe83ea47abc96d77ae96e3e4eb4580f6f396fc"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3adc8532f5029931e82c9ae6a07b5d866b216b422cedc72074155c80db6e27d7"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c46f0573b0455a234c397fff2f3679e18925eb3da32069cc41f1aab7cd968260"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:86c68b283223375ff942bce5b9f2b286fa5ac94b02f848e52fcec2369a407b22"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:452e53346d52241fbebdb9487e88786221c92d4abfa59fb002dc928ada69399c"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fb5fbcb8b45c9f9823a1bffffe8eab673e463b8d36b258856035725e04baf446"}, - {file = "cmake-3.22.3-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:e615d29c2c26faf7e3876c47bafbab0eefe29683e01bec3a14736e9694bdff73"}, - {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:1d6096da730d2d0c8352926b647d0d340fc2ea3a6497dd13cff1c999d68d9d7b"}, - {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_i686.whl", hash = "sha256:d3be0f5256bfe76c81d2db30216c937a7f7cefd251fb63c1cb30c5e0a896bbad"}, - {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_ppc64le.whl", hash = "sha256:d73961a801ea9e2fdda9afa3b9fc84539e368ecec30de1ef54045abfabce4ece"}, - {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_s390x.whl", hash = "sha256:45e89f6ff37283ecff912c7fe65dc4bc6dfe2fb78b7747b95272dd7423a3847f"}, - {file = "cmake-3.22.3-py2.py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:c776ad422f7ce3866497f132af4ba7240cb81d554ee5eb801fd5e2d8c7cd67d6"}, - {file = "cmake-3.22.3-py2.py3-none-win32.whl", hash = "sha256:8d32168fb3153313408befc7b8b5593130bad7d5fe0b8df764bb723b8c710bfc"}, - {file = "cmake-3.22.3-py2.py3-none-win_amd64.whl", hash = "sha256:d8db320fb36560fcf2ca66481009bc1d1f8ed45fd756ce91e4dee97026a0e3a4"}, - {file = "cmake-3.22.3.tar.gz", hash = "sha256:6e1d1991775915dac047af851f2feec7eb35ab4b4610d3e7fd94d93bce8faf58"}, -] "colorama 0.4.4" = [ {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, diff --git a/pyproject.toml b/pyproject.toml index 2ca02b2..e53f743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ requires-python = ">=3.10" dependencies = [ "click>=8.0.3", - "cmake>=3.22.3", "pydantic>=1.9", "tomlkit>=0.10.0", "cppython-core>=0.1.0", From fc8f198f4e6deb0f3a1cdaf418ea226f302c66cb Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Sun, 13 Mar 2022 23:46:35 -0400 Subject: [PATCH 18/22] Remove Pydantic --- pdm.lock | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pdm.lock b/pdm.lock index e687a0a..c1ad90e 100644 --- a/pdm.lock +++ b/pdm.lock @@ -245,7 +245,7 @@ summary = "Module for decorators, wrappers and monkey patching." [metadata] lock_version = "3.1" -content_hash = "sha256:5575b531874fd1b232066c415f5a99fadf1a79121acf890d6182446767ddc8cf" +content_hash = "sha256:e92be1dd34586ba9857865cf3ce269e012b9e89d2d4514c7683d44103deeb373" [metadata.files] "astroid 2.9.3" = [ diff --git a/pyproject.toml b/pyproject.toml index e53f743..dae7976 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,6 @@ requires-python = ">=3.10" dependencies = [ "click>=8.0.3", - "pydantic>=1.9", "tomlkit>=0.10.0", "cppython-core>=0.1.0", ] From bcc5a85a90302988646ddde481d7c96d5624e875 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 17 Mar 2022 14:54:44 -0400 Subject: [PATCH 19/22] Update Chore --- pdm.lock | 16 ++++++++-------- pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pdm.lock b/pdm.lock index c1ad90e..e484f8c 100644 --- a/pdm.lock +++ b/pdm.lock @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "cppython-core" -version = "0.1.0" +version = "0.1.1" requires_python = ">=3.10" summary = "Data definitions for CPPython" dependencies = [ @@ -209,7 +209,7 @@ dependencies = [ [[package]] name = "setuptools" -version = "60.9.3" +version = "60.10.0" requires_python = ">=3.7" summary = "Easily download, build, install, upgrade, and uninstall Python packages" @@ -336,9 +336,9 @@ content_hash = "sha256:e92be1dd34586ba9857865cf3ce269e012b9e89d2d4514c7683d44103 {file = "coverage-6.3.2-pp36.pp37.pp38-none-any.whl", hash = "sha256:18d520c6860515a771708937d2f78f63cc47ab3b80cb78e86573b0a760161faf"}, {file = "coverage-6.3.2.tar.gz", hash = "sha256:03e2a7826086b91ef345ff18742ee9fc47a6839ccd517061ef8fa1976e652ce9"}, ] -"cppython-core 0.1.0" = [ - {file = "cppython_core-0.1.0-py3-none-any.whl", hash = "sha256:97a7c5132eb0fb4c5703d31509e73a746f66576957ebca77b216a50940153d40"}, - {file = "cppython-core-0.1.0.tar.gz", hash = "sha256:2993b038d0d2591be46a8afe6d21ec87c51f634d51d83fed10bd4b5c8ef2df50"}, +"cppython-core 0.1.1" = [ + {file = "cppython_core-0.1.1-py3-none-any.whl", hash = "sha256:5ea0027328417d22f2f718a883bafeac1b049fed84db06f0ab925a89149ef897"}, + {file = "cppython-core-0.1.1.tar.gz", hash = "sha256:5df3d04010661f88f778317978eb3d5319976fa72d3289ec2a2b437daf717901"}, ] "iniconfig 1.1.1" = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, @@ -476,9 +476,9 @@ content_hash = "sha256:e92be1dd34586ba9857865cf3ce269e012b9e89d2d4514c7683d44103 {file = "pytest_mock-3.7.0-py3-none-any.whl", hash = "sha256:6cff27cec936bf81dc5ee87f07132b807bcda51106b5ec4b90a04331cba76231"}, {file = "pytest-mock-3.7.0.tar.gz", hash = "sha256:5112bd92cc9f186ee96e1a92efc84969ea494939c3aead39c50f421c4cc69534"}, ] -"setuptools 60.9.3" = [ - {file = "setuptools-60.9.3-py3-none-any.whl", hash = "sha256:e4f30b9f84e5ab3decf945113119649fec09c1fc3507c6ebffec75646c56e62b"}, - {file = "setuptools-60.9.3.tar.gz", hash = "sha256:2347b2b432c891a863acadca2da9ac101eae6169b1d3dfee2ec605ecd50dbfe5"}, +"setuptools 60.10.0" = [ + {file = "setuptools-60.10.0-py3-none-any.whl", hash = "sha256:782ef48d58982ddb49920c11a0c5c9c0b02e7d7d1c2ad0aa44e1a1e133051c96"}, + {file = "setuptools-60.10.0.tar.gz", hash = "sha256:6599055eeb23bfef457d5605d33a4d68804266e6cb430b0fb12417c5efeae36c"}, ] "toml 0.10.2" = [ {file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"}, diff --git a/pyproject.toml b/pyproject.toml index dae7976..b9710b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ requires-python = ">=3.10" dependencies = [ "click>=8.0.3", "tomlkit>=0.10.0", - "cppython-core>=0.1.0", + "cppython-core>=0.1.1", ] [project.license-files] From b79a3cbb1c6b98b918e294b0191ef2af77191555 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 17 Mar 2022 18:57:27 -0400 Subject: [PATCH 20/22] Basic Verbosity --- cppython/project.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cppython/project.py b/cppython/project.py index b6991b5..c345af7 100644 --- a/cppython/project.py +++ b/cppython/project.py @@ -2,26 +2,45 @@ The central delegation of the CPPython project """ +from dataclasses import dataclass from importlib import metadata from typing import Callable, Optional, Type, TypeVar +from xmlrpc.client import Boolean from cppython_core.exceptions import ConfigError from cppython_core.schema import API, Generator, Interface, Plugin, PyProject +@dataclass +class ProjectConfiguration: + """ + TODO + """ + + verbose: Boolean = False + + class Project(API): """ The object constructed at each entry_point """ - def __init__(self, interface: Interface, pyproject: PyProject) -> None: + def __init__(self, configuration: ProjectConfiguration, interface: Interface, pyproject: PyProject) -> None: self.enabled = False + self.verbose = configuration.verbose + + if self.verbose: + interface.print("Starting CPPython project initialization") if pyproject.tool is None: + if self.verbose: + interface.print("Table [tool] is not defined") return if pyproject.tool.cppython is None: + if self.verbose: + interface.print("Table [tool.cppython] is not defined") return self.enabled = True @@ -53,6 +72,9 @@ def find_plugin_type(plugin_type: PluginType, condition: Callable[[str], bool]) generator_data = interface.read_generator_data(plugin_type.data_type()) self._generator = plugin_type(pyproject, generator_data) + if self.verbose: + interface.print("CPPython project initialized") + def download(self): """ Download the generator tooling if required @@ -68,13 +90,19 @@ def download(self): def install(self) -> None: if self.enabled: + if self.verbose: + self._interface.print("CPPython: Installing...") self.download() self._generator.install() def update(self) -> None: if self.enabled: + if self.verbose: + self._interface.print("CPPython: Updating...") self._generator.update() def build(self) -> None: if self.enabled: + if self.verbose: + self._interface.print("CPPython: Building...") self._generator.build() From 251a271a82fc003f0b452095d79a3b268f9521af Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 17 Mar 2022 19:21:45 -0400 Subject: [PATCH 21/22] Update Test With Config --- cppython/console.py | 6 ++++-- cppython/plugins/__init__.py | 1 - tests/unit/test_interface.py | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) delete mode 100644 cppython/plugins/__init__.py diff --git a/cppython/console.py b/cppython/console.py index b3699d7..85c6374 100644 --- a/cppython/console.py +++ b/cppython/console.py @@ -9,7 +9,7 @@ import tomlkit from cppython_core.schema import GeneratorDataType, Interface, PyProject -from cppython.project import Project +from cppython.project import Project, ProjectConfiguration def _create_pyproject(): @@ -43,8 +43,10 @@ def __init__(self): # Initialize the object hook into CPPython interface = ConsoleInterface() + configuration = ProjectConfiguration() + # Initialize the CPPython context - self.project = Project(interface, pyproject) + self.project = Project(configuration, interface, pyproject) pass_config = click.make_pass_decorator(Config) diff --git a/cppython/plugins/__init__.py b/cppython/plugins/__init__.py deleted file mode 100644 index 5f28270..0000000 --- a/cppython/plugins/__init__.py +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tests/unit/test_interface.py b/tests/unit/test_interface.py index cf12fab..be11f16 100644 --- a/tests/unit/test_interface.py +++ b/tests/unit/test_interface.py @@ -55,3 +55,10 @@ def test_command(self, command: str, mocker: MockerFixture): assert result.exit_code == 0 mocked_command.assert_called_once() + + def test_config(self): + """ + TODO + """ + + config = Config() From 1b82bcf3d4a05f5587a5a6bd5659ca818ca404d7 Mon Sep 17 00:00:00 2001 From: Asher Norland Date: Thu, 17 Mar 2022 20:46:01 -0400 Subject: [PATCH 22/22] Remove Cleanup + Add Verbosity --- cppython/console.py | 54 ++++++++++++++++++++---------------- tests/unit/test_interface.py | 15 ++++++++++ 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/cppython/console.py b/cppython/console.py index 85c6374..50474ee 100644 --- a/cppython/console.py +++ b/cppython/console.py @@ -4,6 +4,7 @@ from pathlib import Path from typing import Type +from xmlrpc.client import Boolean import click import tomlkit @@ -38,62 +39,67 @@ class Config: """ def __init__(self): - pyproject = _create_pyproject() + self.pyproject = _create_pyproject() + self.interface = ConsoleInterface() + self.configuration = ProjectConfiguration() - # Initialize the object hook into CPPython - interface = ConsoleInterface() - - configuration = ProjectConfiguration() - - # Initialize the CPPython context - self.project = Project(configuration, interface, pyproject) + def create_project(self) -> Project: + """ + TODO + """ + return Project(self.configuration, self.interface, self.pyproject) -pass_config = click.make_pass_decorator(Config) +pass_config = click.make_pass_decorator(Config, ensure=True) @click.group() -@click.pass_context -def cli(context): +@click.option("-v", "--verbose", is_flag=True, help="Print additional output") +@pass_config +def cli(config, verbose: Boolean): """ entry_point group for the CLI commands """ - context.ensure_object(Config) + config.configuration.verbose = verbose @cli.command() @pass_config -def install(config): +def info(config): """ - Fulfills the 'install' API requirement + TODO """ - config.project.install() + project = config.create_project() @cli.command() @pass_config -def update(config): +def install(config): """ - Fulfills the 'update' API requirement + TODO """ - config.project.update() + project = config.create_project() + project.install() @cli.command() @pass_config -def build(config): +def update(config): """ - Fulfills the 'build' API requirement + TODO """ - config.project.build() + project = config.create_project() + project.update() -@cli.result_callback() +@cli.command() @pass_config -def cleanup(config, result): +def build(config): """ - Post-command cleanup + TODO """ + project = config.create_project() + project.build() class ConsoleInterface(Interface): diff --git a/tests/unit/test_interface.py b/tests/unit/test_interface.py index be11f16..ba862fd 100644 --- a/tests/unit/test_interface.py +++ b/tests/unit/test_interface.py @@ -10,6 +10,7 @@ from cppython.console import Config, ConsoleInterface, cli from cppython.data import default_pyproject +from cppython.project import ProjectConfiguration class TestCLIInterface(InterfaceUnitTests): @@ -61,4 +62,18 @@ def test_config(self): TODO """ + Config() + + def test_verbosity(self): + """ + TODO + """ + config = Config() + + runner = CliRunner() + result = runner.invoke(cli, "-v info", obj=config, catch_exceptions=False) + + assert result.exit_code == 0 + + assert config.configuration.verbose