-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build-project): rewrite script entries when using custom top nam…
…espace (#50) * feat(build-project): rewrite script entries when using custom top namespace * add unit tests for the TOML generate functions * bump version to 1.4.0
- Loading branch information
1 parent
5ea83d8
commit 5ba524a
Showing
4 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from typing import Union | ||
|
||
import tomlkit | ||
|
||
from poetry_multiproject_plugin.components.toml import generate | ||
|
||
pyproject_lib = """\ | ||
[tool.poetry] | ||
packages = [ | ||
{include = "hello", from = "../world"}, | ||
] | ||
""" | ||
|
||
pyproject_cli = """\ | ||
[tool.poetry] | ||
packages = [ | ||
{include = "hello", from = "../world"}, | ||
] | ||
[tool.poetry.scripts] | ||
my_cli = "my.console.app:run" | ||
""" | ||
|
||
|
||
def generate_toml(pyproj: str, ns: Union[str, None]) -> tomlkit.TOMLDocument: | ||
data = tomlkit.loads(pyproj) | ||
|
||
res = generate.generate_valid_dist_project_file(data, ns) | ||
|
||
return tomlkit.loads(res) | ||
|
||
|
||
def test_generate_project_file_without_any_changes(): | ||
data = generate_toml(pyproject_lib, None) | ||
|
||
assert data["tool"]["poetry"]["packages"] == [{"include": "hello"}] | ||
|
||
|
||
def test_generate_project_file_with_custom_namespace_for_packages(): | ||
data = generate_toml(pyproject_lib, "xyz") | ||
|
||
assert data["tool"]["poetry"]["packages"] == [{"include": "xyz"}] | ||
|
||
|
||
def test_generate_project_file_with_custom_namespace_in_script_entry_point(): | ||
data = generate_toml(pyproject_cli, "xyz") | ||
|
||
assert data["tool"]["poetry"]["scripts"] == {"my_cli": "xyz.my.console.app:run"} | ||
|
||
|
||
def test_generate_project_file_with_unchanged_script_entry_point(): | ||
data = generate_toml(pyproject_cli, "my") | ||
|
||
assert data["tool"]["poetry"]["scripts"] == {"my_cli": "my.console.app:run"} | ||
|
||
|
||
def test_generate_project_file_with_unchanged_script_entry_point_when_ns_is_in_path(): | ||
data = generate_toml(pyproject_cli, "console") | ||
|
||
assert data["tool"]["poetry"]["scripts"] == {"my_cli": "my.console.app:run"} |