requests_mock.Adapter

Here are the examples of the python api requests_mock.Adapter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

7 Examples 7

Example 1

Project: f5-ansible
Source File: bigip_user.py
View license
def fake_http_server(uri, **kwargs):
    session = requests.Session()
    adapter = requests_mock.Adapter()
    session.mount('mock', adapter)
    adapter.register_uri('GET', uri, **kwargs)
    return session

Example 2

Project: f5-common-python
Source File: test_mixins.py
View license
def fake_http_server(uri, **kwargs):
    session = requests.Session()
    adapter = requests_mock.Adapter()
    session.mount('mock', adapter)
    adapter.register_uri('GET', uri, **kwargs)
    return session

Example 3

View license
def fake_http_server(uri, **kwargs):
    session = requests.Session()
    adapter = requests_mock.Adapter()
    session.mount('mock', adapter)
    adapter.register_uri('GET', uri, **kwargs)
    return session

Example 4

Project: valor
Source File: fixtures.py
View license
@pytest.fixture
def session():
    sess = requests.Session()
    sess.requests_mock = requests_mock.Adapter()
    sess.mount('http://', sess.requests_mock)
    sess.mount('https://', sess.requests_mock)
    return sess

Example 5

Project: fjord
Source File: test_adapter.py
View license
    def setUp(self):
        super(SessionAdapterTests, self).setUp()

        self.adapter = requests_mock.Adapter()
        self.session = requests.Session()
        self.session.mount(self.PREFIX, self.adapter)

        self.url = '%s://example.com/test' % self.PREFIX
        self.headers = {'header_a': 'A', 'header_b': 'B'}

Example 6

Project: fjord
Source File: test_adapter.py
View license
    def setUp(self):
        super(SessionAdapterTests, self).setUp()

        self.adapter = requests_mock.Adapter()
        self.session = requests.Session()
        self.session.mount(self.PREFIX, self.adapter)

        self.url = '%s://example.com/test' % self.PREFIX
        self.headers = {'header_a': 'A', 'header_b': 'B'}

Example 7

Project: requests-mock
Source File: test_adapter.py
View license
    def setUp(self):
        super(SessionAdapterTests, self).setUp()

        self.adapter = requests_mock.Adapter()
        self.session = requests.Session()
        self.session.mount(self.PREFIX, self.adapter)

        self.url = '%s://example.com/test' % self.PREFIX
        self.headers = {'header_a': 'A', 'header_b': 'B'}