text: import CommonServerPython
  import RemoveFileWrapper
  
  test_data = [CommonServerPython.CommandRunner.Result(command='endpoint',
                                                       args={
                                                           'id': 'device1,device2',
                                                           'using-brand': 'CrowdstrikeFalcon'},
                                                       brand='CrowdstrikeFalcon',
                                                       instance='CrowdstrikeFalcon_instance_1',
                                                       result={'errors': [], 'resources': [{
                                                           'device_id': 'device1',
                                                           'platform_name': 'Windows'}, {
                                                           'device_id': 'device2',
                                                           'platform_name': 'Linux'}]})]
  
  
  def test_get_crowdstrike_os_to_id(mocker):
      """
      Given:
          A list of devices ids which are on crowdstrike
      When:
          Getting the os for each device
      Then:
          Return a mapping between an OS and a set of device-ids what are on the OS.
  
      """
      from RemoveFileWrapper import get_crowdstrike_os_to_id
      mocker.patch.object(RemoveFileWrapper.CommandRunner, 'execute_commands',
                          return_value=(test_data, []))
      os_to_id = get_crowdstrike_os_to_id(['device2', 'device1'])
      assert os_to_id == {'Windows': {'device1'}, 'Linux': {'device2'}}
  
  
  def test_create_command_executers(mocker):
      """
      Given:
          the action to perform (allow or block)
      When:
          Calling `create_command_wrappers` to get all the command wrappers for the script.
      Then:
          Ensure the right commands wrappers are being returned.
  
      """
      from RemoveFileWrapper import demisto, create_commands
      device_ids = ['device1',
                    'device2',
                    'device3',
                    'device4']
      file_path = 'filepath'
      mocker.patch.object(demisto, 'incident', return_value={'id': 1})
      mocker.patch.object(RemoveFileWrapper, 'get_crowdstrike_os_to_id', return_value={'Windows': {'device1', 'device2'},
                                                                                       'Linux': {'device3'},
                                                                                       'Mac': {'device4'}})
      commands = create_commands(device_ids, file_path)
      assert len(commands) == 2
      for command in commands:
          command_names = set(command.commands)
          if 'xdr-run-script-delete-file' in command_names:
              assert command_names == {'xdr-run-script-delete-file'}
              assert command.args_lst == [{'endpoint_ids': ','.join(device_ids),
                                           'file_path': file_path}]
          if 'cs-falcon-rtr-remove-file' in command_names:
              assert len(command.commands) == 3
              assert len(command.args_lst) == 3
              assert command_names == {'cs-falcon-rtr-remove-file'}
              assert command.args_lst[0].get('host_ids') in {'device1,device2', 'device2,device1'}
              assert command.args_lst[1:] == [
                  {'host_ids': 'device3',
                   'file_path': file_path,
                   'os': 'Linux'
                   },
                  {'host_ids': 'device4',
                   'file_path': file_path,
                   'os': 'Mac',
                   }
              ]
  