mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 22:30:22 -07:00
[wip] Remove network content (#84)
* rebase * remove broken symlinks * more deletes * restore cs_* integration tests * More deletes - from Felix * cs_common * Remove some more ignores
This commit is contained in:
parent
8d203225d3
commit
c313c825f4
2215 changed files with 0 additions and 333978 deletions
|
@ -1,104 +0,0 @@
|
|||
{
|
||||
"mock_single_obj": {
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "PG-123",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
"mock_multiple_obj": {
|
||||
"results": [
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0682",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-2084-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0231",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-1627-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-1627-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-1627-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0535",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-1934-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-1934-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-1934-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0094",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-1458-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-1458-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-1458-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0437",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-1836-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-1836-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-1836-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
},
|
||||
{
|
||||
"_last_modified": "",
|
||||
"cloud_ref": "https://192.0.2.132/api/cloud/cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"dhcp_enabled": true,
|
||||
"exclude_discovered_subnets": false,
|
||||
"name": "J-PG-0673",
|
||||
"synced_from_se": true,
|
||||
"tenant_ref": "https://192.0.2.132/api/tenant/admin",
|
||||
"url": "https://192.0.2.132/api/network/dvportgroup-2075-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"uuid": "dvportgroup-2075-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vcenter_dvs": true,
|
||||
"vimgrnw_ref": "https://192.0.2.132/api/vimgrnwruntime/dvportgroup-2075-cloud-4d063be1-99c2-44cf-8b28-977bd970524c",
|
||||
"vrf_context_ref": "https://192.0.2.132/api/vrfcontext/vrfcontext-31f1b55f-319c-44eb-862f-69d79ffdf295"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2019, Sandeep Bandi <sandeepb@avinetworks.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import json
|
||||
|
||||
from ansible_collections.community.general.tests.unit.compat.mock import patch, MagicMock
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.loader import lookup_loader
|
||||
from ansible_collections.community.general.plugins.lookup import avi
|
||||
|
||||
|
||||
try:
|
||||
import builtins as __builtin__
|
||||
except ImportError:
|
||||
import __builtin__
|
||||
|
||||
|
||||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||
|
||||
with open(fixture_path + '/avi.json') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_credentials():
|
||||
dummy_credentials = {}
|
||||
dummy_credentials['controller'] = "192.0.2.13"
|
||||
dummy_credentials['username'] = "admin"
|
||||
dummy_credentials['password'] = "password"
|
||||
dummy_credentials['api_version'] = "17.2.14"
|
||||
dummy_credentials['tenant'] = 'admin'
|
||||
return dummy_credentials
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def super_switcher(scope="function", autouse=True):
|
||||
# Mocking the inbuilt super as it is used in ApiSession initialization
|
||||
original_super = __builtin__.super
|
||||
__builtin__.super = MagicMock()
|
||||
yield
|
||||
# Revert the super to default state
|
||||
__builtin__.super = original_super
|
||||
|
||||
|
||||
def test_lookup_multiple_obj(dummy_credentials):
|
||||
avi_lookup = lookup_loader.get('community.general.avi')
|
||||
avi_mock = MagicMock()
|
||||
avi_mock.return_value.get.return_value.json.return_value = data["mock_multiple_obj"]
|
||||
with patch.object(avi, 'ApiSession', avi_mock):
|
||||
retval = avi_lookup.run([], {}, avi_credentials=dummy_credentials,
|
||||
obj_type="network")
|
||||
assert retval == data["mock_multiple_obj"]["results"]
|
||||
|
||||
|
||||
def test_lookup_single_obj(dummy_credentials):
|
||||
avi_lookup = lookup_loader.get('community.general.avi')
|
||||
avi_mock = MagicMock()
|
||||
avi_mock.return_value.get_object_by_name.return_value = data["mock_single_obj"]
|
||||
with patch.object(avi, 'ApiSession', avi_mock):
|
||||
retval = avi_lookup.run([], {}, avi_credentials=dummy_credentials,
|
||||
obj_type="network", obj_name='PG-123')
|
||||
assert retval[0] == data["mock_single_obj"]
|
||||
|
||||
|
||||
def test_invalid_lookup(dummy_credentials):
|
||||
avi_lookup = lookup_loader.get('community.general.avi')
|
||||
avi_mock = MagicMock()
|
||||
with pytest.raises(AnsibleError):
|
||||
with patch.object(avi, 'ApiSession', avi_mock):
|
||||
avi_lookup.run([], {}, avi_credentials=dummy_credentials)
|
Loading…
Add table
Add a link
Reference in a new issue