How to use the apiron.client.build_request_object function in apiron

To help you get started, we’ve selected a few apiron 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 ithaka / apiron / tests / test_client.py View on Github external
def test_build_request_object_raises_no_host_exception(self):
        service = mock.Mock()
        service.get_hosts.return_value = []

        with pytest.raises(NoHostsAvailableException):
            client.build_request_object(None, service, None)
github ithaka / apiron / tests / test_client.py View on Github external
params = {"baz": "qux"}
        mock_endpoint.get_merged_params.return_value = params
        data = "I am a data"
        files = {"file_name": io.BytesIO(b"this is a test")}
        json = {"raw": "data"}
        headers = {"Accept": "stuff"}
        cookies = {"chocolate-chip": "yes"}
        auth = mock.Mock()

        mock_get_required_headers.return_value = {"header": "value"}
        expected_headers = {}
        expected_headers.update(headers)
        expected_headers.update(mock_endpoint.required_headers)

        with mock.patch.object(session, "prepare_request") as mock_prepare_request:
            client.build_request_object(
                session,
                service,
                mock_endpoint,
                params=params,
                data=data,
                files=files,
                json=json,
                headers=headers,
                cookies=cookies,
                auth=auth,
                foo="bar",
            )

            mock_request_constructor.assert_called_once_with(
                url="http://host1.biz/foo/",
                method=mock_endpoint.default_method,