Exemplo n.º 1
0
def test_create_incident_wrong_args():
    """
    Given:
        - An app client object
    When:
        - Calling function create_incident 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_incident(mock_client, {'responders': ['team', 'id']})
Exemplo n.º 2
0
def test_create_incident(mocker):
    """
    Given:
        - An app client object
    When:
        - Calling function create_incident
    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_incident',
                        return_value=util_load_json('test_data/request.json'))
    mocker.patch.object(mock_client,
                        'get_request',
                        return_value=util_load_json(
                            'test_data/create_incident.json', True))
    res = OpsGenieV3.create_incident(mock_client, {})
    assert (
        res.raw_response == util_load_json('test_data/create_incident.json'))