def setUp(self): """Setup.""" super(TestCreateJavaKeystore, self).setUp() orig_exists = os.path.exists self.spec = ArgumentSpec() self.mock_create_file = patch( 'ansible_collections.community.general.plugins.modules.system.java_keystore.create_file', side_effect=lambda path, content: path) self.mock_run_commands = patch( 'ansible_collections.community.general.plugins.modules.system.java_keystore.run_commands' ) self.mock_os_path_exists = patch( 'os.path.exists', side_effect=lambda path: True if path == '/path/to/keystore.jks' else orig_exists(path)) self.mock_selinux_context = patch( 'ansible.module_utils.basic.AnsibleModule.selinux_context', side_effect=lambda path: ['unconfined_u', 'object_r', 'user_home_t', 's0']) self.mock_is_special_selinux_path = patch( 'ansible.module_utils.basic.AnsibleModule.is_special_selinux_path', side_effect=lambda path: (False, None)) self.run_commands = self.mock_run_commands.start() self.create_file = self.mock_create_file.start() self.selinux_context = self.mock_selinux_context.start() self.is_special_selinux_path = self.mock_is_special_selinux_path.start( ) self.os_path_exists = self.mock_os_path_exists.start()
def setUp(self): """Setup.""" super(TestCertChanged, self).setUp() self.spec = ArgumentSpec() self.mock_create_file = patch('ansible_collections.community.general.plugins.modules.system.java_keystore.create_file') self.mock_run_commands = patch('ansible_collections.community.general.plugins.modules.system.java_keystore.run_commands') self.run_commands = self.mock_run_commands.start() self.create_file = self.mock_create_file.start()
def setUp(self): """Setup.""" super(TestCertChanged, self).setUp() self.spec = ArgumentSpec() self.mock_create_file = patch( 'ansible_collections.community.general.plugins.modules.system.java_keystore.create_file' ) self.mock_run_command = patch( 'ansible.module_utils.basic.AnsibleModule.run_command') self.mock_get_bin_path = patch( 'ansible.module_utils.basic.AnsibleModule.get_bin_path') self.run_command = self.mock_run_command.start() self.create_file = self.mock_create_file.start() self.get_bin_path = self.mock_get_bin_path.start()