<commit_before>import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *

''' IMPORTS '''
import dateparser
from datetime import datetime, timedelta

server_url = 'https://vigilant.alienvault.cloud/api/2.0/alarms?page=1&size=1' \
             '&sort=timestamp_occured%2Casc&timestamp_occured_gte=1547567249000'


def approximate_compare(time1, time2):
    if isinstance(time1, int):
        time1 = datetime.fromtimestamp(time1 / 1000)
    if isinstance(time2, int):
        time2 = datetime.fromtimestamp(time2 / 1000)

    return timedelta(seconds=-30) <= time1 - time2 <= timedelta(seconds=3)


def test_fetch_incidents(mocker, requests_mock):
    mocker.patch.object(demisto, 'params', return_value={
        'fetch_limit': '1',
        'url': 'https://vigilant.alienvault.cloud/'
    })
    mocker.patch.object(demisto, 'getLastRun', return_value={'time': '2019-01-15T15:47:29.959Z'})
    mocker.patch.object(demisto, 'setLastRun')
    mocker.patch.object(demisto, 'incidents')
    from AlienVault_USM_Anywhere import fetch_incidents
    requests_mock.get(
        server_url,
        json={
            '_embedded': {
                'alarms': [
                    {
                        'uuid': '444444444',
                        'timestamp_occured_iso8601': '2019-07-12T06:00:38.000Z',
                    }
                ]
            },
            'page': {
                'totalElements': 1861<commit_msg>just to check hooks<commit_after>import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *

''' IMPORTS '''
import dateparser
from datetime import datetime, timedelta

server_url = 'https://vigilant.alienvault.cloud/api/2.0/alarms?page=1&size=1' \
             '&sort=timestamp_occured%2Casc&timestamp_occured_gte=1547567249000'


def approximate_compare(time1, time2):
    if isinstance(time1, int):
        time1 = datetime.fromtimestamp(time1 / 1000)
    if isinstance(time2, int):
        time2 = datetime.fromtimestamp(time2 / 1000)

    return timedelta(seconds=-30) <= time1 - time2 <= timedelta(seconds=3)


def test_fetch_incidents(mocker, requests_mock):
    mocker.patch.object(demisto, 'params', return_value={
        'fetch_limit': '1',
        'url': 'https://vigilant.alienvault.cloud/'
    })
    mocker.patch.object(demisto, 'getLastRun', return_value={'time': '2019-01-15T15:47:29.959Z'})
    mocker.patch.object(demisto, 'setLastRun')
    mocker.patch.object(demisto, 'incidents')
    from AlienVault_USM_Anywhere import fetch_incidents
    requests_mock.get(
        server_url,
        json={
            '_embedded': {
                'alarms': [
                    {
                        'uuid': '4444444444',
                        'timestamp_occured_iso8601': '2019-07-12T06:00:38.000Z',
                    }
                ]
            },
            'page': {
                'totalElements': 1861
{'fraction_non_alphanumeric': 0.1216445803601767, 'fraction_numerical': 0.06218144750254842, 'mean_word_length': 2.5728155339805827, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5527963', 'n_tokens_mistral': 1053, 'n_tokens_neox': 922, 'n_words': 152}