def test_main(mocker): args = dict(get_args()) mocker.patch.object(demisto, 'args', return_value=args) mocker.patch.object(demisto, 'executeCommand', side_effect=execute_command_get_incidents) entry = main() assert "Fetched 2 incidents successfully" in entry['HumanReadable'] assert 'GetIncidentsByQuery' in entry['EntryContext'] assert 'status' in entry['Contents'][0] assert 'context' not in entry['Contents'][0] assert 'testValue' == entry['Contents'][0]['testField'] args['includeContext'] = 'true' entry = main() assert {} == entry['Contents'][0]['context'] args['populateFields'] = 'testField,status' args['NonEmptyFields'] = 'severity' entry = main() assert set(entry['Contents'][0].keys()) == set( ['testField', 'status', 'severity', 'id', 'context']) args.pop('fromDate') entry = main() assert set(entry['Contents'][0].keys()) == set( ['testField', 'status', 'severity', 'id', 'context'])
def test_main(mocker): args = get_args() mocker.patch.object(demisto, 'args', return_value=args) mocker.patch.object(demisto, 'executeCommand', return_value=[{ 'Type': entryTypes['note'], 'Contents': { 'data': [incident1, incident2] } }]) entry = main() assert "Fetched 2 incidents successfully" in entry['HumanReadable'] assert 'GetIncidentsByQuery' in entry['EntryContext'] assert 'status' in entry['Contents'][0] assert 'context' not in entry['Contents'][0] assert 'testValue' == entry['Contents'][0]['testField'] args['includeContext'] = 'true' entry = main() assert {} == entry['Contents'][0]['context'] args['populateFields'] = 'testField,status' args['NonEmptyFields'] = 'severity' entry = main() assert set(entry['Contents'][0].keys()) == set( ['testField', 'status', 'severity']) args.pop('fromDate') entry = main() assert set(entry['Contents'][0].keys()) == set( ['testField', 'status', 'severity'])
def test_skip_python_magic(mocker): args = dict(get_args()) mocker.patch.object(demisto, 'args', return_value=args) mocker.patch.object(demisto, 'executeCommand', side_effect=execute_command_get_incidents_with_magic) entry = main() assert entry['Contents'][0]['id'] == 1 assert len(entry['Contents']) == 1
def test_main(mocker): args = get_args() mocker.patch.object(demisto, 'args', return_value=args) mocker.patch.object(demisto, 'executeCommand', return_value=[{ 'Type': entryTypes['note'], 'Contents': { 'data': [incident1, incident2] } }]) entry = main() assert "Fetched 2 incidents successfully" in entry['HumanReadable'] assert 'GetIncidentsByQuery' in entry['EntryContext'] assert 'status' in entry['Contents'][0] assert 'context' not in entry['Contents'][0] assert 'testValue' == entry['Contents'][0]['testField'] args['includeContext'] = 'true' entry = main() assert {} == entry['Contents'][0]['context']