mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-05-13 13:02:04 +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
|
kubevirt
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_NAMESPACE = "default"
|
DEFAULT_NAMESPACE = "default"
|
||||||
DEFAULT_BASE_DOMAIN = "example.com"
|
DEFAULT_BASE_DOMAIN = "example.com"
|
||||||
|
|
||||||
@@ -233,6 +232,7 @@ def add_group(monkeypatch, inventory):
|
|||||||
def add_group(name):
|
def add_group(name):
|
||||||
if name not in groups:
|
if name not in groups:
|
||||||
groups.append(name)
|
groups.append(name)
|
||||||
|
return name
|
||||||
|
|
||||||
monkeypatch.setattr(inventory.inventory, "add_group", add_group)
|
monkeypatch.setattr(inventory.inventory, "add_group", add_group)
|
||||||
return groups
|
return groups
|
||||||
@@ -242,9 +242,11 @@ def add_group(monkeypatch, inventory):
|
|||||||
def add_host(monkeypatch, inventory):
|
def add_host(monkeypatch, inventory):
|
||||||
hosts = []
|
hosts = []
|
||||||
|
|
||||||
def add_host(name):
|
def add_host(name, group=None):
|
||||||
if name not in hosts:
|
if name not in hosts:
|
||||||
hosts.append(name)
|
hosts.append(name)
|
||||||
|
if group is not None and group not in hosts:
|
||||||
|
hosts.append(group)
|
||||||
|
|
||||||
monkeypatch.setattr(inventory.inventory, "add_host", add_host)
|
monkeypatch.setattr(inventory.inventory, "add_host", add_host)
|
||||||
return hosts
|
return hosts
|
||||||
|
|||||||
Reference in New Issue
Block a user