New module: xenserver_guest_powerstate - manages powerstate of XenServer VMs (#49425)

* Initial commit for xenserver_guest_powerstate module
* Added unit tests for the module, removed unused imports
This commit is contained in:
Bojan Vitnik 2019-02-28 13:25:05 +01:00 committed by Abhijeet Kasurde
parent 4d3a6123d5
commit 88e8330e3e
4 changed files with 614 additions and 0 deletions

View file

@ -11,6 +11,24 @@ import sys
import importlib
import pytest
from .FakeAnsibleModule import FakeAnsibleModule
@pytest.fixture
def fake_ansible_module(request):
"""Returns fake AnsibleModule with fake module params."""
if hasattr(request, 'param'):
return FakeAnsibleModule(request.param)
else:
params = {
"hostname": "somehost",
"username": "someuser",
"password": "somepwd",
"validate_certs": True,
}
return FakeAnsibleModule(params)
@pytest.fixture(autouse=True)
def XenAPI():
@ -42,3 +60,16 @@ def xenserver_guest_facts(XenAPI):
from ansible.modules.cloud.xenserver import xenserver_guest_facts
return xenserver_guest_facts
@pytest.fixture
def xenserver_guest_powerstate(XenAPI):
"""Imports and returns xenserver_guest_powerstate module."""
# Since we are wrapping fake XenAPI module inside a fixture, all modules
# that depend on it have to be imported inside a test function. To make
# this easier to handle and remove some code repetition, we wrap the import
# of xenserver_guest_powerstate module with a fixture.
from ansible.modules.cloud.xenserver import xenserver_guest_powerstate
return xenserver_guest_powerstate