def test_get_time_range():
    from AlienVault_USM_Anywhere import get_time_range
    from CommonServerPython import date_to_timestamp

    assert get_time_range(None, None, None) == (None, None)

    dt = datetime.now()
    start, end = get_time_range('Today', None, None)
    assert datetime.fromtimestamp(start / 1000).date() == dt.date() and approximate_compare(dt, end)

    dt = datetime.now()
    # should ignore the start/end time values
    start, end = get_time_range('Today', 'asfd', 'asdf')
    assert datetime.fromtimestamp(start / 1000).date() == dt.date() and approximate_compare(dt, end)

    dt = datetime.now()
    start, end = get_time_range('Yesterday', None, None)
    assert datetime.fromtimestamp(start / 1000).date() == (dt.date() - timedelta(days=1)) and approximate_compare(dt, end)

    start, end = get_time_range('Custom', '2019-12-30T01:02:03Z', '2019-12-30T04:05:06Z')
    assert ((start, end) == (date_to_timestamp(dateparser.parse('2019-12-30T01:02:03Z')),
                             date_to_timestamp(dateparser.parse('2019-12-30T04:05:06Z'))))

    start, end = get_time_range('Custom', '2019-12-30T01:02:03Z', None)
    assert (start == date_to_timestamp(dateparser.parse('2019-12-30T01:02:03Z'))
            and approximate_compare(end, datetime.now()))
def test_date_to_timestamp():
    assert date_to_timestamp('2018-11-06T08:56:41') == 1541494601000
    assert date_to_timestamp(
        datetime.strptime('2018-11-06T08:56:41',
                          "%Y-%m-%dT%H:%M:%S")) == 1541494601000
Beispiel #3
0
                ' Pending,Closed,Reopened,New,In Progress,Resolved,Assigned | false |\n'

ONE_TEP_ACTIONS_HR = '### Config Item Tasks one-step actions:\n' \
                     '|Name|Display Name|Description|Id|Association|Stand In Key|\n' \
                     '|---|---|---|---|---|---|\n' \
                     '| Call Contact | Call Contact | Launches Skype to contact the Customer. | 9389e70ed88b993cff6c66' \
                     ' | 6dd536621cf6434ae | DefType:OneStepDef#Scope:Global#Id:9389e70ed88b73a6b1393434ae |\n' \
                     '### Buttons one-step actions:\n' \
                     '|Name|Display Name|Description|Id|Association|Stand In Key|\n' \
                     '|---|---|---|---|---|---|\n' \
                     '| Cancel Incident | Cancel Incident | Abandons the incident and opens the default dashboard |' \
                     ' 944414556c072e6e430 | 6dd53665ccf6434ae | DefType:OneStepDef#Scope:Global#Id:944434ae |\n'

INTEGRATION_CONTEXT = {
    'token_expiration_time':
    date_to_timestamp(datetime.now() + timedelta(days=1)),
    'access_token': 'TOKEN'
}


@patch('Cherwell.BASE_URL',
       'https://demisto.experiencecherwell.com/CherwellAPI/')
def test_cherwell_get_business_object_summary_command(mocker, requests_mock):
    """
    When:
        Execute cherwell-get-business-object-summary command.
    Then:
        Validate the command results is correct.
    """
    mocker.patch.object(demisto, 'args', return_value={'name': 'incident'})
    mocker.patch.object(demisto,