def test_last_scan(mock_connect, mock_send, mock_info):
    """Check if last_scan function returns expected datetime according to the database"""
    result = rootcheck.last_scan('001')
    assert result == {
        'end': '2020-10-27T12:29:40Z',
        'start': '2020-10-27T12:19:40Z'
    }
Example #2
0
def get_last_scan(agent_list):
    """Get the last rootcheck scan of the agent.

    Parameters
    ----------
    agent_list : list
        Agent ID to get the last scan date from.

    Returns
    -------
    result : AffectedItemsWazuhResult
        JSON containing the scan date.
    """
    result = AffectedItemsWazuhResult(all_msg='Last rootcheck scan of the agent was returned',
                                      none_msg='No last scan information was returned')

    result.affected_items.append(last_scan(agent_list[0]))
    result.total_affected_items = len(result.affected_items)

    return result