예제 #1
0
def test_get_request_command_404(requests_mock, mocker):
    """
      Given:
          - A call to get-retquest
      When:
          - response is 404
      Then:
          - Scheduledcommand is returned
      """
    mocker.patch(
        'CommonServerPython.ScheduledCommand.raise_error_if_not_supported')
    requests_mock.get(url='http://example.com/v2/alert/requests/1',
                      status_code=404)
    args = {'request_id': 1, 'request_type': 'alert'}
    response = OpsGenieV3.get_request_command(
        OpsGenieV3.Client(base_url="http://example.com"), args)
    assert response.scheduled_command._args == {**args, 'polled_once': True}
예제 #2
0
def test_get_request_command(requests_mock, mocker):
    """
    Given:
        - A call to get-retquest
    When:
        - response is successful
    Then:
        - output is returned
    """
    output = {'hello': 'world'}
    mocker.patch(
        'CommonServerPython.ScheduledCommand.raise_error_if_not_supported')
    requests_mock.get(url='http://example.com/v2/alert/requests/1',
                      json={'data': output})
    args = {'request_id': 1, 'request_type': 'alert'}
    response = OpsGenieV3.get_request_command(
        OpsGenieV3.Client(base_url="http://example.com"), args)
    assert response.outputs == output