def test_incident_creation_e6(): from Elasticsearch_v2 import results_to_incidents_datetime last_fetch = parse('2019-08-29T14:44:00Z') incidents, last_fetch2 = results_to_incidents_datetime( ES_V6_RESPONSE, last_fetch) assert str(last_fetch2) == '2019-08-29T14:46:00Z' assert str(incidents) == MOCK_ES6_INCIDETNS
def test_incident_creation_e7(): from Elasticsearch_v2 import results_to_incidents_datetime last_fetch = parse('2019-08-27T17:59:00') incidents, last_fetch2 = results_to_incidents_datetime( ES_V7_RESPONSE, last_fetch) assert str(last_fetch2) == '2019-08-27T18:01:00Z' assert str(incidents) == MOCK_ES7_INCIDENTS
def test_incident_creation_e7(params, mocker): mocker.patch.object(demisto, 'params', return_value=params) importlib.reload( Elasticsearch_v2 ) # To reset the Elasticsearch client with the OpenSearch library from Elasticsearch_v2 import results_to_incidents_datetime last_fetch = parse('2019-08-27T17:59:00') incidents, last_fetch2 = results_to_incidents_datetime( ES_V7_RESPONSE, last_fetch) assert str(last_fetch2) == '2019-08-27T18:01:00Z' assert str(incidents) == MOCK_ES7_INCIDENTS
def test_incident_creation_e6(params, mocker): mocker.patch.object(demisto, 'params', return_value=params) importlib.reload( Elasticsearch_v2 ) # To reset the Elasticsearch client with the OpenSearch library from Elasticsearch_v2 import results_to_incidents_datetime last_fetch = parse('2019-08-29T14:44:00Z') incidents, last_fetch2 = results_to_incidents_datetime( ES_V6_RESPONSE, last_fetch) assert str(last_fetch2) == '2019-08-29T14:46:00Z' if params.get('map_labels'): assert str(incidents) == MOCK_ES6_INCIDETNS else: assert str(incidents) == MOCK_ES6_INCIDETNS_WITHOUT_LABELS
def test_incident_creation_e7(params, mocker): mocker.patch.object(demisto, 'params', return_value=params) importlib.reload( Elasticsearch_v2 ) # To reset the Elasticsearch client with the OpenSearch library from Elasticsearch_v2 import results_to_incidents_datetime last_fetch = parse('2019-08-27T17:59:00') incidents, last_fetch2 = results_to_incidents_datetime( ES_V7_RESPONSE, last_fetch) # last fetch should not truncate the milliseconds assert str(last_fetch2) == '2019-08-27T18:01:25.343212+00:00' if params.get('map_labels'): assert str(incidents) == MOCK_ES7_INCIDENTS else: assert str(incidents) == MOCK_ES7_INCIDENTS_WITHOUT_LABELS