Example #1
0
def test_create_alert_wrong_responders():
    """
    Given:
        - An app client object
    When:
        - Calling function create_alert with argument responders in the wrong format
    Then:
        - Ensure the resulted will raise an exception.
    """
    mock_client = OpsGenieV3.Client(base_url="")
    with pytest.raises(DemistoException):
        OpsGenieV3.create_alert(mock_client, {'responders': ['team', 'id']})
Example #2
0
def test_create_alert(mocker):
    """
    Given:
        - An app client object
        - Responders "team,id,123"
    When:
        - Calling function create_alert with argument responders in the right format
    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,
                        'create_alert',
                        return_value=util_load_json('test_data/request.json'))
    mocker.patch.object(mock_client,
                        'get_request',
                        return_value=util_load_json(
                            'test_data/create_alert.json', True))
    res = OpsGenieV3.create_alert(mock_client, {'responders': "team,id,123"})
    assert (res.raw_response == util_load_json('test_data/create_alert.json'))