8000 Add a check in config to set project type as playbook by shatakshiiii · Pull Request #306 · ansible/ansible-creator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a check in config to set project type as playbook #306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/ansible_creator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Config:

def __post_init__(self: Config) -> None:
"""Post process config values."""
if self.project == "ansible-project":
object.__setattr__(self, "project", "playbook")

if self.collection:
fqcn = self.collection.split(".", maxsplit=1)
object.__setattr__(self, "namespace", fqcn[0])
Expand Down
22 changes: 22 additions & 0 deletions tests/units/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,25 @@ def test_coming_soon(
stdout, stderr = capsys.readouterr()
assert f"`{args}` command is coming soon" in stdout
assert "Goodbye" in stderr


def test_config_post_init(
tmp_path: Path,
output: Output,
) -> None:
"""Test for a check in post_init in Config class.

Args:
tmp_path: Temporary directory path.
output: Output class object.
"""
config = Config(
creator_version="24.10.0",
output=output,
subcommand="init",
collection="foo.bar",
init_path=str(tmp_path / "test_path"),
project="ansible-project",
)
config.__post_init__()
assert config.project == "playbook"
0