mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Remove all usage of ansible.module_utils.six from main branch (#10888)
* Get rid of all six.moves imports. * Get rid of iteritems. * Get rid of *_type(s) aliases. * Replace StringIO import. * Get rid of PY2/PY3 constants. * Get rid of raise_from. * Get rid of python_2_unicode_compatible. * Clean up global six imports. * Remove all usage of ansible.module_utils.six. * Linting. * Fix xml module. * Docs adjustments.
This commit is contained in:
parent
8f8a0e1d7c
commit
a8977afb04
113 changed files with 188 additions and 352 deletions
|
|
@ -6,18 +6,16 @@ from __future__ import annotations
|
|||
|
||||
import contextlib as _contextlib
|
||||
import json
|
||||
from collections.abc import MutableMapping
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils import deps
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args as _set_module_args
|
||||
|
||||
|
||||
def _fix_ansible_args(args):
|
||||
if isinstance(args, string_types):
|
||||
if isinstance(args, str):
|
||||
# This should be deprecated!
|
||||
return json.loads(args)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from __future__ import annotations
|
|||
from io import BytesIO
|
||||
import json
|
||||
from collections import OrderedDict
|
||||
from collections.abc import Mapping
|
||||
|
||||
from ansible_collections.community.general.plugins.modules.jenkins_plugin import JenkinsPlugin
|
||||
from ansible.module_utils.six.moves.collections_abc import Mapping
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import (
|
||||
MagicMock,
|
||||
patch,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_authentication
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_authentication_flow_by_alias=None, copy_auth_flow=None, create_empty_auth_flow=None,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_authentication_required_actions
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(
|
||||
|
|
|
|||
|
|
@ -14,10 +14,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_client
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_client_by_clientid=None, get_client_by_id=None, update_client=None, create_client=None,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_client_rolemapping
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_group_by_name=None, get_client_id=None, get_client_role_id_by_name=None,
|
||||
|
|
|
|||
|
|
@ -14,10 +14,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_clientscope
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_clientscope_by_name=None, get_clientscope_by_clientscopeid=None, create_clientscope=None,
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from __future__ import annotations
|
|||
|
||||
|
||||
from contextlib import contextmanager
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_realm_key
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat import unittest
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_identity_provider
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_identity_provider, create_identity_provider=None, update_identity_provider=None, delete_identity_provider=None,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_realm
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_realm_by_id, create_realm=None, update_realm=None, delete_realm=None):
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_realm_info
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_realm_info_by_id):
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_realm_key
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_components=None, get_component=None, create_component=None, update_component=None, delete_component=None):
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ from __future__ import annotations
|
|||
|
||||
|
||||
from contextlib import contextmanager
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
from ansible_collections.community.general.plugins.modules import \
|
||||
keycloak_realm_keys_metadata_info
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat import unittest
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_role
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_realm_role=None, create_realm_role=None, update_realm_role=None, delete_realm_role=None,
|
||||
|
|
|
|||
|
|
@ -14,10 +14,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_user
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_user_by_username=None,
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_user_federation
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_components=None, get_component=None, create_component=None, update_component=None, delete_component=None):
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
from ansible_collections.community.general.plugins.modules import keycloak_userprofile
|
||||
|
||||
from io import StringIO
|
||||
from itertools import count
|
||||
|
||||
from json import dumps
|
||||
|
||||
from ansible.module_utils.six import StringIO
|
||||
|
||||
|
||||
@contextmanager
|
||||
def patch_keycloak_api(get_components=None, get_component=None, create_component=None, update_component=None, delete_component=None):
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from __future__ import annotations
|
|||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat.mock import patch
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.compat import unittest
|
||||
|
|
@ -14,7 +15,6 @@ from ansible.module_utils import basic
|
|||
import ansible_collections.community.general.plugins.modules.ocapi_command as module
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import set_module_args, exit_json, fail_json
|
||||
from ansible.module_utils.six.moves.urllib.parse import urljoin
|
||||
|
||||
|
||||
MOCK_BASE_URI = "mockBaseUri/"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from __future__ import annotations
|
|||
import sys
|
||||
|
||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible_collections.community.general.plugins.modules import (
|
||||
pritunl_org,
|
||||
)
|
||||
|
|
@ -108,7 +107,7 @@ class TestPritunlOrg(ModuleTestCase):
|
|||
|
||||
# Ensure both calls resulted in the same returned value
|
||||
# except for changed which should be false the second time
|
||||
for k, v in iteritems(idempotent_exc):
|
||||
for k, v in idempotent_exc.items():
|
||||
if k == "changed":
|
||||
self.assertFalse(idempotent_exc[k])
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from __future__ import annotations
|
|||
import sys
|
||||
|
||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible_collections.community.general.plugins.modules import (
|
||||
pritunl_user,
|
||||
)
|
||||
|
|
@ -153,7 +152,7 @@ class TestPritunlUser(ModuleTestCase):
|
|||
update_exc = update_result.exception.args[0]
|
||||
|
||||
# Ensure only certain settings changed and the rest remained untouched.
|
||||
for k, v in iteritems(update_exc):
|
||||
for k, v in update_exc.items():
|
||||
if k in new_user_params:
|
||||
assert update_exc[k] == v
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue