mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-03-27 03:13:10 +00:00
feat: refactor add_group and add_host fixtures.
It refactors fixtures: `add_group` and `add_host` to improve fixtures reusability in further scenarios. Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
This commit is contained in:
@@ -27,7 +27,6 @@ from ansible_collections.kubevirt.core.plugins.inventory import (
|
||||
kubevirt
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_NAMESPACE = "default"
|
||||
DEFAULT_BASE_DOMAIN = "example.com"
|
||||
|
||||
@@ -233,6 +232,7 @@ def add_group(monkeypatch, inventory):
|
||||
def add_group(name):
|
||||
if name not in groups:
|
||||
groups.append(name)
|
||||
return name
|
||||
|
||||
monkeypatch.setattr(inventory.inventory, "add_group", add_group)
|
||||
return groups
|
||||
@@ -242,9 +242,11 @@ def add_group(monkeypatch, inventory):
|
||||
def add_host(monkeypatch, inventory):
|
||||
hosts = []
|
||||
|
||||
def add_host(name):
|
||||
def add_host(name, group=None):
|
||||
if name not in hosts:
|
||||
hosts.append(name)
|
||||
if group is not None and group not in hosts:
|
||||
hosts.append(group)
|
||||
|
||||
monkeypatch.setattr(inventory.inventory, "add_host", add_host)
|
||||
return hosts
|
||||
|
||||
Reference in New Issue
Block a user