@@ -3,7 +3,10 @@
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"build": "echo build"
|
||||
"build": "echo build",
|
||||
"test": "echo test",
|
||||
"format": "echo format",
|
||||
"lint": "echo lint"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^29.2.2"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "example"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = []
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23.1.0"
|
||||
pytest = "^7.2.2"
|
||||
isort = "^5.12.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
+23
-2
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from project_manager.common.command import CommandExecutor
|
||||
from project_manager.entry.detector import EntryDetector
|
||||
from project_manager.entry.entry import Entry, PartialTaskKey
|
||||
from project_manager.preset.detector import PresetEntryDetector
|
||||
@@ -29,6 +30,24 @@ def entry(entry_detector: EntryDetector, entry_path: Path, tmp_path: Path):
|
||||
return entry_detector.detect_entry(destination, destination)
|
||||
|
||||
|
||||
class FakeCommandExecutor(CommandExecutor):
|
||||
def run(self, basepath: Path) -> dict | None:
|
||||
if self._command == "npm install":
|
||||
(basepath / "node_modules").mkdir(exist_ok=True)
|
||||
elif self._command == "poetry install --all-extras":
|
||||
bin_dir = basepath / ".venv/bin"
|
||||
bin_dir.mkdir(parents=True, exist_ok=True)
|
||||
(bin_dir / "pytest").write_text("")
|
||||
(bin_dir / "pylint").write_text("")
|
||||
(bin_dir / "isort").write_text("")
|
||||
(bin_dir / "black").write_text("")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def entry_command_executor():
|
||||
Entry.DEFAULT_EXECUTOR = FakeCommandExecutor
|
||||
|
||||
|
||||
@pytest.mark.parametrize("entry_path", [Path(__file__).parent / "python"])
|
||||
def test_python_entry(entry: Entry | None, entry_detector: EntryDetector):
|
||||
assert entry is not None
|
||||
@@ -44,10 +63,12 @@ def test_python_entry(entry: Entry | None, entry_detector: EntryDetector):
|
||||
@pytest.mark.parametrize("entry_path", [Path(__file__).parent / "nodejs"])
|
||||
def test_nodejs_entry(entry: Entry | None, entry_detector: EntryDetector):
|
||||
assert entry is not None
|
||||
assert {"setup", "build"} == {task.key.name for task in entry._tasks}
|
||||
assert {"setup", "build", "lint", "format", "test"} == {
|
||||
task.key.name for task in entry._tasks
|
||||
}
|
||||
entry.run_task(PartialTaskKey.from_str("setup"))
|
||||
entry = entry_detector.detect_entry(entry._basepath, entry._basepath)
|
||||
assert entry is not None
|
||||
assert {"setup", "build", "test", "clean"} == {
|
||||
assert {"setup", "build", "lint", "format", "test", "clean"} == {
|
||||
task.key.name for task in entry._tasks
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user