def test_sanity(mocker): mocker.patch.object(demisto, 'args', return_value={ 'CampaignIncidentType': 'Phishing Campaign', 'IncidentIDs': '11,21' }) mocker.patch.object( demisto, 'executeCommand', side_effect=[ _wrap_mocked_get_incident_by_query(PHISHING_CAMPAIGN_INCIDENTS) ] + [ _wrap_mocked_get_context(incident) for incident in PHISHING_CAMPAIGN_INCIDENTS ]) results = main() assert results.readable_output == "Found campaign with ID - 1" assert results.outputs['ExistingCampaignID'] == '1' mocker.patch.object( demisto, 'executeCommand', side_effect=[_wrap_mocked_get_incident_by_query([])]) results = main() assert results.readable_output == "No campaign has found" assert results.outputs['ExistingCampaignID'] is None
def test_main_pagination(mocker): """ Given a campaign incident type incident ID part of a campaign When calling the script Then return the correct campaign ID which appears in the second incidents page """ mocker.patch.object(demisto, 'args', return_value={ 'CampaignIncidentType': 'Phishing Campaign', 'IncidentIDs': '123' }) mocker.patch.object( demisto, 'executeCommand', side_effect=[ _wrap_mocked_get_incident(OTHER_INCIDENTS * 2), _wrap_mocked_get_incident(PHISHING_CAMPAIGN_INCIDENTS), _wrap_mocked_get_context({ 'EmailCampaign': { 'incidents': [{ 'id': '11' }, { 'id': '12' }] } }), _wrap_mocked_get_context({ 'EmailCampaign': { 'incidents': [{ 'id': '11' }, { 'id': '123' }] } }), ]) results = main() assert results.readable_output == 'Found campaign with ID - 2' assert results.outputs['ExistingCampaignID'] == '2'
def test_where_no_campaign_ids(mocker): """ Given Incidents to check if they are part of campaign. When Getting some incidents campaign ids which are not related to the given incident ids. Then Ensure the results returned nothing. """ import IsIncidentPartOfCampaign mocker.patch.object(demisto, 'args', return_value={}) mocker.patch.object(IsIncidentPartOfCampaign, 'get_incidents_ids_by_type', return_value=[1, 2, 3]) mocker.patch.object(IsIncidentPartOfCampaign, 'check_incidents_ids_in_campaign', return_value=False) command_results = main() assert command_results.readable_output == "No campaign has found" assert command_results.outputs['ExistingCampaignID'] is None