How to use the pdpyras.APISession.raise_if_http_error function in pdpyras

To help you get started, we’ve selected a few pdpyras examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PagerDuty / pdpyras / test_pdpyras.py View on Github external
import json
import logging
import os
import requests
import sys
import unittest

if sys.version_info.major < 3:
    import backports.unittest_mock
    backports.unittest_mock.install()

from unittest.mock import MagicMock, patch, call

import pdpyras

pdpyras.APISession.raise_if_http_error = True

class Session(object):
    """
    Python reqeusts.Session mockery class
    """
    request = None
    headers = None

class Response(object):
    """Mock class for emulating requests.Response objects

    Look for existing use of this class for examples on how to use.
    """

    def __init__(self, code, text, method='GET', url=None):
        super(Response, self).__init__()