diff options
Diffstat (limited to 'test/units/modules/cloud')
-rw-r--r-- | test/units/modules/cloud/__init__.py | 0 | ||||
-rw-r--r-- | test/units/modules/cloud/linode/__init__.py | 0 | ||||
-rw-r--r-- | test/units/modules/cloud/linode/conftest.py | 80 | ||||
-rw-r--r-- | test/units/modules/cloud/xenserver/__init__.py | 0 | ||||
-rw-r--r-- | test/units/modules/cloud/xenserver/conftest.py | 75 |
5 files changed, 0 insertions, 155 deletions
diff --git a/test/units/modules/cloud/__init__.py b/test/units/modules/cloud/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/units/modules/cloud/__init__.py +++ /dev/null diff --git a/test/units/modules/cloud/linode/__init__.py b/test/units/modules/cloud/linode/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/units/modules/cloud/linode/__init__.py +++ /dev/null diff --git a/test/units/modules/cloud/linode/conftest.py b/test/units/modules/cloud/linode/conftest.py deleted file mode 100644 index 9a7d7371f5..0000000000 --- a/test/units/modules/cloud/linode/conftest.py +++ /dev/null @@ -1,80 +0,0 @@ -import pytest - - -@pytest.fixture -def api_key(monkeypatch): - monkeypatch.setenv('LINODE_API_KEY', 'foobar') - - -@pytest.fixture -def auth(monkeypatch): - def patched_test_echo(dummy): - return [] - monkeypatch.setattr('linode.api.Api.test_echo', patched_test_echo) - - -@pytest.fixture -def access_token(monkeypatch): - monkeypatch.setenv('LINODE_ACCESS_TOKEN', 'barfoo') - - -@pytest.fixture -def no_access_token_in_env(monkeypatch): - try: - monkeypatch.delenv('LINODE_ACCESS_TOKEN') - except KeyError: - pass - - -@pytest.fixture -def default_args(): - return {'state': 'present', 'label': 'foo'} - - -@pytest.fixture -def mock_linode(): - class Linode(): - def delete(self, *args, **kwargs): - pass - - @property - def _raw_json(self): - return { - "alerts": { - "cpu": 90, - "io": 10000, - "network_in": 10, - "network_out": 10, - "transfer_quota": 80 - }, - "backups": { - "enabled": False, - "schedule": { - "day": None, - "window": None, - } - }, - "created": "2018-09-26T08:12:33", - "group": "Foobar Group", - "hypervisor": "kvm", - "id": 10480444, - "image": "linode/centos7", - "ipv4": [ - "130.132.285.233" - ], - "ipv6": "2a82:7e00::h03c:46ff:fe04:5cd2/64", - "label": "lin-foo", - "region": "eu-west", - "specs": { - "disk": 25600, - "memory": 1024, - "transfer": 1000, - "vcpus": 1 - }, - "status": "running", - "tags": [], - "type": "g6-nanode-1", - "updated": "2018-09-26T10:10:14", - "watchdog_enabled": True - } - return Linode() diff --git a/test/units/modules/cloud/xenserver/__init__.py b/test/units/modules/cloud/xenserver/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/units/modules/cloud/xenserver/__init__.py +++ /dev/null diff --git a/test/units/modules/cloud/xenserver/conftest.py b/test/units/modules/cloud/xenserver/conftest.py deleted file mode 100644 index f93b6c60b4..0000000000 --- a/test/units/modules/cloud/xenserver/conftest.py +++ /dev/null @@ -1,75 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright: (c) 2019, Bojan Vitnik <bvitnik@mainstream.rs> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -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(): - """Imports and returns fake XenAPI module.""" - - # Import of fake XenAPI module is wrapped by fixture so that it does not - # affect other unit tests which could potentialy also use XenAPI module. - - # First we use importlib.import_module() to import the module and assign - # it to a local symbol. - fake_xenapi = importlib.import_module('units.modules.cloud.xenserver.FakeXenAPI') - - # Now we populate Python module cache with imported fake module using the - # original module name (XenAPI). That way, any 'import XenAPI' statement - # will just load already imported fake module from the cache. - sys.modules['XenAPI'] = fake_xenapi - - return fake_xenapi - - -@pytest.fixture -def xenserver_guest_info(XenAPI): - """Imports and returns xenserver_guest_info 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_info module with a fixture. - from ansible.modules.cloud.xenserver import xenserver_guest_info - - return xenserver_guest_info - - -@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 |