mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-20 10:48:59 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -7,7 +7,11 @@ from __future__ import annotations
|
|||
|
||||
from unittest.mock import call, patch
|
||||
from ansible_collections.community.general.plugins.modules import ipa_getkeytab
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, ModuleTestCase, set_module_args
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import (
|
||||
AnsibleExitJson,
|
||||
ModuleTestCase,
|
||||
set_module_args,
|
||||
)
|
||||
|
||||
|
||||
class IPAKeytabModuleTestCase(ModuleTestCase):
|
||||
|
|
@ -16,11 +20,11 @@ class IPAKeytabModuleTestCase(ModuleTestCase):
|
|||
def setUp(self):
|
||||
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.mock_run_command = patch(f"{ansible_module_path}.run_command")
|
||||
self.module_main_command = self.mock_run_command.start()
|
||||
self.mock_get_bin_path = patch(f'{ansible_module_path}.get_bin_path')
|
||||
self.mock_get_bin_path = patch(f"{ansible_module_path}.get_bin_path")
|
||||
self.get_bin_path = self.mock_get_bin_path.start()
|
||||
self.get_bin_path.return_value = '/testbin/ipa_getkeytab'
|
||||
self.get_bin_path.return_value = "/testbin/ipa_getkeytab"
|
||||
|
||||
def tearDown(self):
|
||||
self.mock_run_command.stop()
|
||||
|
|
@ -33,26 +37,35 @@ class IPAKeytabModuleTestCase(ModuleTestCase):
|
|||
return exc.exception.args[0]
|
||||
|
||||
def test_present(self):
|
||||
with set_module_args({
|
||||
'path': '/tmp/test.keytab',
|
||||
'principal': 'HTTP/freeipa-dc02.ipa.test',
|
||||
'ipa_host': 'freeipa-dc01.ipa.test',
|
||||
'state': 'present'
|
||||
}):
|
||||
with set_module_args(
|
||||
{
|
||||
"path": "/tmp/test.keytab",
|
||||
"principal": "HTTP/freeipa-dc02.ipa.test",
|
||||
"ipa_host": "freeipa-dc01.ipa.test",
|
||||
"state": "present",
|
||||
}
|
||||
):
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{}', ''),
|
||||
(0, "{}", ""),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/ipa_getkeytab',
|
||||
'--keytab', '/tmp/test.keytab',
|
||||
'--server', 'freeipa-dc01.ipa.test',
|
||||
'--principal', 'HTTP/freeipa-dc02.ipa.test'
|
||||
],
|
||||
check_rc=True,
|
||||
environ_update={'LC_ALL': 'C', 'LANGUAGE': 'C'}
|
||||
),
|
||||
])
|
||||
self.assertTrue(result["changed"])
|
||||
self.module_main_command.assert_has_calls(
|
||||
[
|
||||
call(
|
||||
[
|
||||
"/testbin/ipa_getkeytab",
|
||||
"--keytab",
|
||||
"/tmp/test.keytab",
|
||||
"--server",
|
||||
"freeipa-dc01.ipa.test",
|
||||
"--principal",
|
||||
"HTTP/freeipa-dc02.ipa.test",
|
||||
],
|
||||
check_rc=True,
|
||||
environ_update={"LC_ALL": "C", "LANGUAGE": "C"},
|
||||
),
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue