mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Cleanup: use super() instead of super(__class__, self) (#11016)
* Address UP008: Use super() instead of super(__class__, self). * Linting.
This commit is contained in:
parent
0c5466de47
commit
74c2c804e5
204 changed files with 390 additions and 401 deletions
|
|
@ -31,7 +31,7 @@ def lxc(request):
|
|||
_container_states = {}
|
||||
|
||||
def __init__(self, name):
|
||||
super(ContainerMock, self).__init__()
|
||||
super().__init__()
|
||||
self.name = name
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from ansible_collections.community.general.plugins.module_utils.hwc_utils import
|
|||
|
||||
class HwcUtilsTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(HwcUtilsTestCase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# Add backward compatibility
|
||||
if sys.version_info < (3, 0):
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ class PritunlDeleteUserMock(MagicMock):
|
|||
|
||||
class ModuleFailException(Exception):
|
||||
def __init__(self, msg, **kwargs):
|
||||
super(ModuleFailException, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
self.fail_msg = msg
|
||||
self.fail_kwargs = kwargs
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def mock_xenapi_failure(XenAPI, mocker):
|
|||
# same side_effect as its parent mock object.
|
||||
class MagicMockSideEffect(MagicMock):
|
||||
def _get_child_mock(self, **kw):
|
||||
child_mock = super(MagicMockSideEffect, self)._get_child_mock(**kw)
|
||||
child_mock = super()._get_child_mock(**kw)
|
||||
child_mock.side_effect = self.side_effect
|
||||
return child_mock
|
||||
|
||||
|
|
|
|||
|
|
@ -69,11 +69,11 @@ def customer_response_page2():
|
|||
class TestAlertaCustomerModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAlertaCustomerModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = alerta_customer
|
||||
|
||||
def tearDown(self):
|
||||
super(TestAlertaCustomerModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from ansible_collections.community.general.plugins.modules.archive import get_ar
|
|||
|
||||
class TestArchive(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestArchive, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_os_path_isdir = patch('os.path.isdir')
|
||||
self.os_path_isdir = self.mock_os_path_isdir.start()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestBucketAccessKeyModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestBucketAccessKeyModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = bitbucket_access_key
|
||||
|
||||
def test_missing_key_with_present_state(self):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestBucketPipelineKeyPairModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestBucketPipelineKeyPairModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = bitbucket_pipeline_key_pair
|
||||
|
||||
def test_missing_keys_with_present_state(self):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestBucketPipelineKnownHostModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestBucketPipelineKnownHostModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = bitbucket_pipeline_known_host
|
||||
|
||||
@pytest.mark.skipif(not HAS_PARAMIKO, reason='paramiko must be installed to test key creation')
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestBucketPipelineVariableModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestBucketPipelineVariableModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = bitbucket_pipeline_variable
|
||||
|
||||
def test_without_required_parameters(self):
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
class TestBootcManageModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBootcManageModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = bootc_manage
|
||||
|
||||
def tearDown(self):
|
||||
super(TestBootcManageModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_switch_without_image(self):
|
||||
"""Failure if state is 'switch' but no image provided"""
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
class TestCampfireModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCampfireModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = campfire
|
||||
|
||||
def tearDown(self):
|
||||
super(TestCampfireModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
class TestCirconusAnnotation(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestCirconusAnnotation, self).setUp()
|
||||
super().setUp()
|
||||
self.module = circonus_annotation
|
||||
|
||||
def tearDown(self):
|
||||
super(TestCirconusAnnotation, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_without_required_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing"""
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ DowntimeRecurrence = datadog_api_client.v1.model.downtime_recurrence.DowntimeRec
|
|||
class TestDatadogDowntime(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDatadogDowntime, self).setUp()
|
||||
super().setUp()
|
||||
self.module = datadog_downtime
|
||||
|
||||
def tearDown(self):
|
||||
super(TestDatadogDowntime, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_without_required_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing"""
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
class TestDiscordModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDiscordModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = discord
|
||||
|
||||
def tearDown(self):
|
||||
super(TestDiscordModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ call_enable_crb = call(['/usr/bin/dnf', 'config-manager', '--assumeyes', '--set-
|
|||
|
||||
class TestDNFConfigManager(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestDNFConfigManager, self).setUp()
|
||||
super().setUp()
|
||||
self.mock_run_command = (patch('ansible.module_utils.basic.AnsibleModule.run_command'))
|
||||
self.run_command = self.mock_run_command.start()
|
||||
self.mock_path_exists = (patch('os.path.exists'))
|
||||
|
|
@ -266,7 +266,7 @@ class TestDNFConfigManager(ModuleTestCase):
|
|||
self.module = dnf_config_manager_module
|
||||
|
||||
def tearDown(self):
|
||||
super(TestDNFConfigManager, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_run_command.stop()
|
||||
self.mock_path_exists.stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ class TestDNSimple(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Setup."""
|
||||
super(TestDNSimple, self).setUp()
|
||||
super().setUp()
|
||||
self.module = dnsimple_module
|
||||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestDNSimple, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_without_required_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing"""
|
||||
|
|
|
|||
|
|
@ -44,12 +44,12 @@ class TestDNSimple_Info(ModuleTestCase):
|
|||
def setUp(self):
|
||||
|
||||
"""Setup."""
|
||||
super(TestDNSimple_Info, self).setUp()
|
||||
super().setUp()
|
||||
self.module = dnsimple_info
|
||||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestDNSimple_Info, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_with_no_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing"""
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ def get_command(run_command):
|
|||
|
||||
class TestGem(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGem, self).setUp()
|
||||
super().setUp()
|
||||
self.rubygems_path = ['/usr/bin/gem']
|
||||
self.mocker.patch(
|
||||
'ansible_collections.community.general.plugins.modules.gem.get_rubygems_path',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ except ImportError:
|
|||
|
||||
class TestGitlabDeployKey(GitlabModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGitlabDeployKey, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.moduleUtil = GitLabDeployKey(module=self.mock_module, gitlab_instance=self.gitlab_instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ except ImportError:
|
|||
|
||||
class TestGitlabGroup(GitlabModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGitlabGroup, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.moduleUtil = GitLabGroup(module=self.mock_module, gitlab_instance=self.gitlab_instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ except ImportError:
|
|||
class TestGitlabGroupAccessToken(GitlabModuleTestCase):
|
||||
@with_httmock(resp_get_user)
|
||||
def setUp(self):
|
||||
super(TestGitlabGroupAccessToken, self).setUp()
|
||||
super().setUp()
|
||||
if not python_gitlab_version_match_requirement():
|
||||
self.skipTest(f"python-gitlab {'.'.join(map(str, PYTHON_GITLAB_MINIMAL_VERSION))}+ is needed for gitlab_group_access_token")
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ except ImportError:
|
|||
|
||||
class TestGitlabHook(GitlabModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGitlabHook, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.moduleUtil = GitLabHook(module=self.mock_module, gitlab_instance=self.gitlab_instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ except ImportError:
|
|||
class TestGitlabProject(GitlabModuleTestCase):
|
||||
@with_httmock(resp_get_user)
|
||||
def setUp(self):
|
||||
super(TestGitlabProject, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.gitlab_instance.user = self.gitlab_instance.users.get(1)
|
||||
self.moduleUtil = GitLabProject(module=self.mock_module, gitlab_instance=self.gitlab_instance)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ except ImportError:
|
|||
class TestGitlabProjectAccessToken(GitlabModuleTestCase):
|
||||
@with_httmock(resp_get_user)
|
||||
def setUp(self):
|
||||
super(TestGitlabProjectAccessToken, self).setUp()
|
||||
super().setUp()
|
||||
if not python_gitlab_version_match_requirement():
|
||||
self.skipTest(f"python-gitlab {'.'.join(map(str, PYTHON_GITLAB_MINIMAL_VERSION))}+ is needed for gitlab_project_access_token")
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class TestGitlabProtectedBranch(GitlabModuleTestCase):
|
|||
@with_httmock(resp_get_project_by_name)
|
||||
@with_httmock(resp_get_user)
|
||||
def setUp(self):
|
||||
super(TestGitlabProtectedBranch, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.gitlab_instance.user = self.gitlab_instance.users.get(1)
|
||||
self.moduleUtil = GitlabProtectedBranch(module=self.mock_module, project="foo-bar/diaspora-client", gitlab_instance=self.gitlab_instance)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ except ImportError:
|
|||
|
||||
class TestGitlabRunner(GitlabModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGitlabRunner, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.module_util_all = GitLabRunner(module=FakeAnsibleModule({"owned": False}), gitlab_instance=self.gitlab_instance)
|
||||
self.module_util_owned = GitLabRunner(module=FakeAnsibleModule({"owned": True}), gitlab_instance=self.gitlab_instance)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ except ImportError:
|
|||
|
||||
class TestGitlabUser(GitlabModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestGitlabUser, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.moduleUtil = GitLabUser(module=self.mock_module, gitlab_instance=self.gitlab_instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TestIcinga2Feature(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Setup."""
|
||||
super(TestIcinga2Feature, self).setUp()
|
||||
super().setUp()
|
||||
self.module = icinga2_feature
|
||||
self.mock_get_bin_path = patch.object(basic.AnsibleModule, 'get_bin_path', get_bin_path)
|
||||
self.mock_get_bin_path.start()
|
||||
|
|
@ -31,7 +31,7 @@ class TestIcinga2Feature(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestIcinga2Feature, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_without_required_parameters(self):
|
||||
"""Failure must occurs when all parameters are missing."""
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class IPAKeytabModuleTestCase(ModuleTestCase):
|
|||
module = ipa_getkeytab
|
||||
|
||||
def setUp(self):
|
||||
super(IPAKeytabModuleTestCase, self).setUp()
|
||||
super().setUp()
|
||||
ansible_module_path = "ansible_collections.community.general.plugins.modules.ipa_getkeytab.AnsibleModule"
|
||||
self.mock_run_command = patch(f'{ansible_module_path}.run_command')
|
||||
self.module_main_command = self.mock_run_command.start()
|
||||
|
|
@ -25,7 +25,7 @@ class IPAKeytabModuleTestCase(ModuleTestCase):
|
|||
def tearDown(self):
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
super(IPAKeytabModuleTestCase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def module_main(self, exit_exc):
|
||||
with self.assertRaises(exit_exc) as exc:
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def patch_ipa(**kwargs):
|
|||
|
||||
class TestIPAOTPConfig(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestIPAOTPConfig, self).setUp()
|
||||
super().setUp()
|
||||
self.module = ipa_otpconfig
|
||||
|
||||
def _test_base(self, module_args, return_value, mock_calls, changed):
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def patch_ipa(**kwargs):
|
|||
|
||||
class TestIPAOTPToken(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestIPAOTPToken, self).setUp()
|
||||
super().setUp()
|
||||
self.module = ipa_otptoken
|
||||
|
||||
def _test_base(self, module_args, return_value, mock_calls, changed):
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def patch_ipa(**kwargs):
|
|||
|
||||
class TestIPAPwPolicy(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestIPAPwPolicy, self).setUp()
|
||||
super().setUp()
|
||||
self.module = ipa_pwpolicy
|
||||
|
||||
def _test_base(self, module_args, return_value, mock_calls, changed):
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class TestCreateJavaKeystore(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Setup."""
|
||||
super(TestCreateJavaKeystore, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
orig_exists = os.path.exists
|
||||
self.mock_create_file = patch('ansible_collections.community.general.plugins.modules.java_keystore.create_file')
|
||||
|
|
@ -67,7 +67,7 @@ class TestCreateJavaKeystore(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestCreateJavaKeystore, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_create_file.stop()
|
||||
self.mock_create_path.stop()
|
||||
self.mock_current_type.stop()
|
||||
|
|
@ -229,7 +229,7 @@ class TestCertChanged(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Setup."""
|
||||
super(TestCertChanged, self).setUp()
|
||||
super().setUp()
|
||||
self.mock_create_file = patch('ansible_collections.community.general.plugins.modules.java_keystore.create_file')
|
||||
self.mock_current_type = patch('ansible_collections.community.general.plugins.modules.java_keystore.JavaKeystore.current_type')
|
||||
self.mock_run_command = patch('ansible.module_utils.basic.AnsibleModule.run_command')
|
||||
|
|
@ -245,7 +245,7 @@ class TestCertChanged(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestCertChanged, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_create_file.stop()
|
||||
self.mock_current_type.stop()
|
||||
self.mock_run_command.stop()
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakAuthentication(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakAuthentication, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_authentication
|
||||
|
||||
def test_create_auth_flow_from_copy(self):
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakAuthentication(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakAuthentication, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_authentication_required_actions
|
||||
|
||||
def test_register_required_action(self):
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealm(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealm, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_client
|
||||
|
||||
def test_authentication_flow_binding_overrides_feature(self):
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealm(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealm, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_client_rolemapping
|
||||
|
||||
def test_map_clientrole_to_group_with_name(self):
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakAuthentication(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakAuthentication, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_clientscope
|
||||
|
||||
def test_create_clientscope(self):
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakComponent(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakComponent, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_component
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakIdentityProvider(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakIdentityProvider, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_identity_provider
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealm(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealm, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_realm
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealmRole(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealmRole, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_realm_info
|
||||
|
||||
def test_get_public_info(self):
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealmKeys(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealmKeys, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_realm_key
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealmRole(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealmRole, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_realm_keys_metadata_info
|
||||
|
||||
def test_get_public_info(self):
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakRealmRole(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakRealmRole, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_role
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
@ -470,7 +470,7 @@ class TestKeycloakRealmRole(ModuleTestCase):
|
|||
|
||||
class TestKeycloakClientRole(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakClientRole, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_role
|
||||
|
||||
def test_create_client_role_with_composites_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakUser(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakUser, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_user
|
||||
|
||||
def test_add_new_user(self):
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakUserFederation(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakUserFederation, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_user_federation
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ def mock_good_connection():
|
|||
|
||||
class TestKeycloakUserprofile(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestKeycloakUserprofile, self).setUp()
|
||||
super().setUp()
|
||||
self.module = keycloak_userprofile
|
||||
|
||||
def test_create_when_absent(self):
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class TestLvgRename(ModuleTestCase):
|
|||
|
||||
def setUp(self):
|
||||
"""Prepare mocks for module testing"""
|
||||
super(TestLvgRename, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_run_responses = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from ansible_collections.community.general.plugins.modules.modprobe import Modpr
|
|||
|
||||
class TestLoadModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestLoadModule, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_module_loaded = patch(
|
||||
'ansible_collections.community.general.plugins.modules.modprobe.Modprobe.module_loaded'
|
||||
|
|
@ -26,7 +26,7 @@ class TestLoadModule(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestLoadModule, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_module_loaded.stop()
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
|
|
@ -73,7 +73,7 @@ class TestLoadModule(ModuleTestCase):
|
|||
|
||||
class TestUnloadModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestUnloadModule, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_module_loaded = patch(
|
||||
'ansible_collections.community.general.plugins.modules.modprobe.Modprobe.module_loaded'
|
||||
|
|
@ -87,7 +87,7 @@ class TestUnloadModule(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestUnloadModule, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_module_loaded.stop()
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
|
|
@ -146,7 +146,7 @@ class TestModuleIsLoadedPersistently(ModuleTestCase):
|
|||
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
|
||||
self.skipTest("open_mock doesn't support readline in earlier python versions")
|
||||
|
||||
super(TestModuleIsLoadedPersistently, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class TestModuleIsLoadedPersistently(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestModuleIsLoadedPersistently, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ class TestPermanentParams(ModuleTestCase):
|
|||
def setUp(self):
|
||||
if sys.version_info[0] == 3 and sys.version_info[1] < 7:
|
||||
self.skipTest("open_mock doesn't support readline in earlier python versions")
|
||||
super(TestPermanentParams, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ class TestPermanentParams(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestPermanentParams, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ class TestPermanentParams(ModuleTestCase):
|
|||
|
||||
class TestCreateModuleFIle(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestCreateModuleFIle, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ class TestCreateModuleFIle(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestCreateModuleFIle, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ class TestCreateModuleFIle(ModuleTestCase):
|
|||
|
||||
class TestCreateModuleOptionsFIle(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestCreateModuleOptionsFIle, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ class TestCreateModuleOptionsFIle(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestCreateModuleOptionsFIle, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ class TestCreateModuleOptionsFIle(ModuleTestCase):
|
|||
|
||||
class TestDisableOldParams(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestDisableOldParams, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -362,7 +362,7 @@ class TestDisableOldParams(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestDisableOldParams, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
@ -412,7 +412,7 @@ class TestDisableOldParams(ModuleTestCase):
|
|||
|
||||
class TestDisableModulePermanent(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestDisableModulePermanent, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.mock_get_bin_path = patch('ansible.module_utils.basic.AnsibleModule.get_bin_path')
|
||||
|
||||
|
|
@ -420,7 +420,7 @@ class TestDisableModulePermanent(ModuleTestCase):
|
|||
|
||||
def tearDown(self):
|
||||
"""Teardown."""
|
||||
super(TestDisableModulePermanent, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -90,11 +90,11 @@ def mock_acl_delete_token():
|
|||
class TestNomadTokenModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNomadTokenModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = nomad_token
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNomadTokenModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_should_fail_without_parameters(self):
|
||||
with self.assertRaises(AnsibleFailJson):
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class NPMModuleTestCase(ModuleTestCase):
|
|||
module = npm
|
||||
|
||||
def setUp(self):
|
||||
super(NPMModuleTestCase, self).setUp()
|
||||
super().setUp()
|
||||
ansible_module_path = "ansible_collections.community.general.plugins.modules.npm.AnsibleModule"
|
||||
self.mock_run_command = patch(f'{ansible_module_path}.run_command')
|
||||
self.module_main_command = self.mock_run_command.start()
|
||||
|
|
@ -26,7 +26,7 @@ class NPMModuleTestCase(ModuleTestCase):
|
|||
def tearDown(self):
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
super(NPMModuleTestCase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def module_main(self, exit_exc):
|
||||
with self.assertRaises(exit_exc) as exc:
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ class Response:
|
|||
|
||||
class TestPagerDutyAlertModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPagerDutyAlertModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pagerduty_alert
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPagerDutyAlertModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestPagerDutyChangeModule(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPagerDutyChangeModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pagerduty_change
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPagerDutyChangeModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ parted_dict3 = {
|
|||
|
||||
class TestParted(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestParted, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.module = parted_module
|
||||
self.mock_check_parted_label = (patch('ansible_collections.community.general.plugins.modules.parted.check_parted_label', return_value=False))
|
||||
|
|
@ -146,7 +146,7 @@ class TestParted(ModuleTestCase):
|
|||
self.get_bin_path = self.mock_get_bin_path.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestParted, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
self.mock_parted.stop()
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ ndctl_list_N_two_namespaces = """[
|
|||
|
||||
class TestPmem(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPmem, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pmem_module
|
||||
|
||||
self.mock_run_command = (patch('ansible.module_utils.basic.AnsibleModule.run_command'))
|
||||
|
|
@ -282,7 +282,7 @@ class TestPmem(ModuleTestCase):
|
|||
self.pmem_init_env = self.mock_pmem_init_env.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPmem, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_get_bin_path.stop()
|
||||
self.mock_run_command.stop()
|
||||
self.mock_pmem_is_dcpmm_installed.stop()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestPritunlOrg(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPritunlOrg, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pritunl_org
|
||||
|
||||
# Add backward compatibility
|
||||
|
|
@ -35,7 +35,7 @@ class TestPritunlOrg(ModuleTestCase):
|
|||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPritunlOrg, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_add_pritunl_organization(self, **kwds):
|
||||
return patch(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestPritunlOrgInfo(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPritunlOrgInfo, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pritunl_org_info
|
||||
|
||||
# Add backward compatibility
|
||||
|
|
@ -32,7 +32,7 @@ class TestPritunlOrgInfo(ModuleTestCase):
|
|||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPritunlOrgInfo, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_get_pritunl_organizations(self, **kwds):
|
||||
return patch(
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def mock_pritunl_api(func, **kwargs):
|
|||
|
||||
class TestPritunlUser(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPritunlUser, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pritunl_user
|
||||
|
||||
# Add backward compatibility
|
||||
|
|
@ -51,7 +51,7 @@ class TestPritunlUser(ModuleTestCase):
|
|||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPritunlUser, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_get_pritunl_users(self, **kwds):
|
||||
return patch(
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
|
||||
class TestPritunlUserInfo(ModuleTestCase):
|
||||
def setUp(self):
|
||||
super(TestPritunlUserInfo, self).setUp()
|
||||
super().setUp()
|
||||
self.module = pritunl_user_info
|
||||
|
||||
# Add backward compatibility
|
||||
|
|
@ -32,7 +32,7 @@ class TestPritunlUserInfo(ModuleTestCase):
|
|||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPritunlUserInfo, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_get_pritunl_users(self, **kwds):
|
||||
return patch(
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ class FakeRedisClientFail(MagicMock):
|
|||
class TestRedisInfoModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRedisInfoModule, self).setUp()
|
||||
super().setUp()
|
||||
redis_info.HAS_REDIS_PACKAGE = True
|
||||
self.module = redis_info
|
||||
|
||||
def tearDown(self):
|
||||
super(TestRedisInfoModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_redis_client(self, **kwds):
|
||||
return patch('ansible_collections.community.general.plugins.modules.redis_info.redis_client', autospec=True, **kwds)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
SUBMAN_KWARGS = dict(check_rc=True, expand_user_and_vars=False)
|
||||
|
||||
def setUp(self):
|
||||
super(RhsmRepositoryReleaseModuleTestCase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# Mainly interested that the subscription-manager calls are right
|
||||
# based on the module args, so patch out run_command in the module.
|
||||
|
|
@ -41,7 +41,7 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
self.mock_os_getuid.stop()
|
||||
super(RhsmRepositoryReleaseModuleTestCase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def module_main(self, exit_exc):
|
||||
with self.assertRaises(exit_exc) as exc:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class RpmOSTreeModuleTestCase(ModuleTestCase):
|
|||
module = rpm_ostree_pkg
|
||||
|
||||
def setUp(self):
|
||||
super(RpmOSTreeModuleTestCase, self).setUp()
|
||||
super().setUp()
|
||||
ansible_module_path = "ansible_collections.community.general.plugins.modules.rpm_ostree_pkg.AnsibleModule"
|
||||
self.mock_run_command = patch(f'{ansible_module_path}.run_command')
|
||||
self.module_main_command = self.mock_run_command.start()
|
||||
|
|
@ -26,7 +26,7 @@ class RpmOSTreeModuleTestCase(ModuleTestCase):
|
|||
def tearDown(self):
|
||||
self.mock_run_command.stop()
|
||||
self.mock_get_bin_path.stop()
|
||||
super(RpmOSTreeModuleTestCase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def module_main(self, exit_exc):
|
||||
with self.assertRaises(exit_exc) as exc:
|
||||
|
|
|
|||
|
|
@ -85,10 +85,10 @@ _TELINIT_STATUS_RUNNING_NOT = """
|
|||
class TestSimpleinitMSB(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSimpleinitMSB, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestSimpleinitMSB, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@patch('os.path.exists', return_value=True)
|
||||
@patch('ansible.module_utils.basic.AnsibleModule.get_bin_path', return_value="/sbin/telinit")
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
|||
class TestSlackModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSlackModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = slack
|
||||
|
||||
def tearDown(self):
|
||||
super(TestSlackModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@pytest.fixture
|
||||
def fetch_url_mock(self, mocker):
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ class FakeStatsD(MagicMock):
|
|||
class TestStatsDModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestStatsDModule, self).setUp()
|
||||
super().setUp()
|
||||
statsd.HAS_STATSD = True
|
||||
self.module = statsd
|
||||
|
||||
def tearDown(self):
|
||||
super(TestStatsDModule, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def patch_udp_statsd_client(self, **kwargs):
|
||||
return patch('ansible_collections.community.general.plugins.modules.statsd.udp_statsd_client', autospec=True, **kwargs)
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ from ansible_collections.community.general.plugins.modules import sysupgrade
|
|||
class TestSysupgradeModule(ModuleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSysupgradeModule, self).setUp()
|
||||
super().setUp()
|
||||
self.module = sysupgrade
|
||||
self.mock_get_bin_path = (patch('ansible.module_utils.basic.AnsibleModule.get_bin_path'))
|
||||
self.get_bin_path = self.mock_get_bin_path.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestSysupgradeModule, self).tearDown()
|
||||
super().tearDown()
|
||||
self.mock_get_bin_path.stop()
|
||||
|
||||
def test_upgrade_success(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue