Skip to content

Commit

Permalink
Added tests for module dispatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
CFSNM committed Oct 2, 2023
1 parent d36978c commit 5285781
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@ cython_debug/
# and should all have detailed explanations

# Version created and populated by setuptools_scm
/src/pytest_ansible/_version.py
/src/pytest_ansible/_version.py

# JetBrains
.idea
5 changes: 5 additions & 0 deletions extra_inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[extrahosts]
extra-host-1.example.com
extra-host-2.example.com
extra-host-3.example.com
extra-host-4.example.com
16 changes: 15 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


ALL_HOSTS = ["another_host", "localhost", "yet_another_host"]
ALL_EXTRA_HOSTS = ["extrahosts"]

POSITIVE_HOST_PATTERNS = [
("all", 3),
Expand All @@ -30,6 +31,7 @@
marks=pytest.mark.requires_ansible_v2(),
), # this is confusing, but how host slicing works on v2
pytest.param("*[0:]", 3, marks=pytest.mark.requires_ansible_v2()),
("extrahosts", 4)
]

NEGATIVE_HOST_PATTERNS = [
Expand Down Expand Up @@ -118,6 +120,18 @@ def __init__(self, config, testdir) -> None:
""",
)

# Create extra inventory file
self.extra_inventory = testdir.makefile(
".ini",
inventory="""
[extrahosts]
extra-host-1.example.com
extra-host-2.example.com
extra-host-3.example.com
extra-host-4.example.com
""",
)

# Create ansible.cfg file

@property
Expand Down Expand Up @@ -148,4 +162,4 @@ def option(request, testdir):
def hosts():
from pytest_ansible.host_manager import get_host_manager

return get_host_manager(inventory=",".join(ALL_HOSTS), connection="local")
return get_host_manager(inventory=",".join(ALL_HOSTS), extra_inventory=",".join(ALL_EXTRA_HOSTS), connection="local")

0 comments on commit 5285781

Please sign in to comment.