Пример #1
0
def test_get_incidents_going_to_right_function():
    """
    Given:
        - An app client object
    When:
        - Calling function get_incidents
        Case A: "incident_id" = 1234
        Case B: No arguments
    Then:
        - Ensure the right function was called
        Case A: Called get_incident
        Case B: Called list_incidents
    """
    mock_client = OpsGenieV3.Client(base_url="")
    mock_client.get_incident = mock.MagicMock()
    OpsGenieV3.get_incidents(mock_client, {"incident_id": 1234})
    assert mock_client.get_incident.called
    OpsGenieV3.list_incidents = mock.MagicMock()
    OpsGenieV3.get_incidents(mock_client, {})
    assert OpsGenieV3.list_incidents.called
Пример #2
0
def test_get_incidents(mocker):
    """
    Given:
        - An app client object
        - limit = 1
    When:
        - Calling function get_incidents
    Then:
        - Ensure the return data is correct
    """
    mocker.patch('CommonServerPython.get_demisto_version',
                 return_value={"version": "6.2.0"})
    mock_client = OpsGenieV3.Client(base_url="")
    mocker.patch.object(
        mock_client,
        'list_incidents',
        return_value=util_load_json('test_data/get_incidents.json'))
    res = OpsGenieV3.get_incidents(mock_client, {"limit": 1})
    assert (len(res.outputs) == 1)