mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
Python3 fixes and porting (#17271)
* Fix to_native call in selinux_context and selinux_default_context to use the error handler correctly. * Port set_mode_if_different to work on python3 * Port atomic_move to work on python3 * Fix check_password_prompt variable which wasn't renamed properly
This commit is contained in:
@@ -804,8 +804,8 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
_os_chown.reset_mock()
|
||||
am.set_context_if_different.reset_mock()
|
||||
am.atomic_move('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with('/path/to/src', '/path/to/dest')
|
||||
self.assertEqual(_os_chmod.call_args_list, [call('/path/to/dest', basic.DEFAULT_PERM & ~18)])
|
||||
_os_rename.assert_called_with(b'/path/to/src', b'/path/to/dest')
|
||||
self.assertEqual(_os_chmod.call_args_list, [call(b'/path/to/dest', basic.DEFAULT_PERM & ~18)])
|
||||
|
||||
# same as above, except selinux_enabled
|
||||
_os_path_exists.side_effect = [False, False]
|
||||
@@ -822,8 +822,8 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
am.set_context_if_different.reset_mock()
|
||||
am.selinux_default_context.reset_mock()
|
||||
am.atomic_move('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with('/path/to/src', '/path/to/dest')
|
||||
self.assertEqual(_os_chmod.call_args_list, [call('/path/to/dest', basic.DEFAULT_PERM & ~18)])
|
||||
_os_rename.assert_called_with(b'/path/to/src', b'/path/to/dest')
|
||||
self.assertEqual(_os_chmod.call_args_list, [call(b'/path/to/dest', basic.DEFAULT_PERM & ~18)])
|
||||
self.assertEqual(am.selinux_default_context.call_args_list, [call('/path/to/dest')])
|
||||
self.assertEqual(am.set_context_if_different.call_args_list, [call('/path/to/dest', mock_context, False)])
|
||||
|
||||
@@ -846,7 +846,7 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
_os_chown.reset_mock()
|
||||
am.set_context_if_different.reset_mock()
|
||||
am.atomic_move('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with(b'/path/to/src', b'/path/to/dest')
|
||||
|
||||
# dest missing, selinux enabled
|
||||
_os_path_exists.side_effect = [True, True]
|
||||
@@ -868,7 +868,7 @@ class TestModuleUtilsBasic(ModuleTestCase):
|
||||
am.set_context_if_different.reset_mock()
|
||||
am.selinux_default_context.reset_mock()
|
||||
am.atomic_move('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with('/path/to/src', '/path/to/dest')
|
||||
_os_rename.assert_called_with(b'/path/to/src', b'/path/to/dest')
|
||||
self.assertEqual(am.selinux_context.call_args_list, [call('/path/to/dest')])
|
||||
self.assertEqual(am.set_context_if_different.call_args_list, [call('/path/to/dest', mock_context, False)])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user