示例#1
0
    def _prepare(self):
        """Builds a URL and return a PreparedRequest.

        Returns
            (requests.PreparedRequest)

        Raises
            UberIllegalState (APIError)
        """
        if self.method not in http.ALLOWED_METHODS:
            raise UberIllegalState('Unsupported HTTP Method.')

        api_host = self.api_host
        headers = self._build_headers(self.method, self.auth_session)
        url = build_url(api_host, self.path)
        data, params = generate_data(self.method, self.args)

        return generate_prepared_request(
            self.method,
            url,
            headers,
            data,
            params,
            self.handlers,
        )
示例#2
0
def test_generate_data_with_PUT(
    default_http_arguments_as_json,
    default_http_arguments_as_string,
):
    """Assign arguments to body of request in PUT."""
    data, params = generate_data('PUT', default_http_arguments_as_json)
    assert not params
    assert data == default_http_arguments_as_string
示例#3
0
def test_generate_data_with_PUT(
    default_http_arguments_as_json,
    default_http_arguments_as_string,
):
    """Assign arguments to body of request in PUT."""
    data, params = generate_data('PUT', default_http_arguments_as_json)
    assert not params
    assert data == default_http_arguments_as_string
示例#4
0
def test_generate_data_with_DELETE(default_http_arguments_as_json,):
    """Assign arguments to querystring params in DELETE."""
    data, params = generate_data('DELETE', default_http_arguments_as_json)
    assert params == default_http_arguments_as_json
    assert not data
示例#5
0
def test_generate_data_with_GET(default_http_arguments_as_json):
    """Assign arguments to querystring params in GET."""
    data, params = generate_data('GET', default_http_arguments_as_json)
    assert params == default_http_arguments_as_json
    assert not data
示例#6
0
def test_generate_data_with_DELETE(default_http_arguments_as_json, ):
    """Assign arguments to querystring params in DELETE."""
    data, params = generate_data('DELETE', default_http_arguments_as_json)
    assert params == default_http_arguments_as_json
    assert not data
示例#7
0
def test_generate_data_with_GET(default_http_arguments_as_json):
    """Assign arguments to querystring params in GET."""
    data, params = generate_data('GET', default_http_arguments_as_json)
    assert params == default_http_arguments_as_json
    assert not data
def test_generate_data_with_PATCH(default_http_arguments_as_json, default_http_arguments_as_string):
    """Assign arguments to body of request in PATCH."""
    data, params = generate_data("PATCH", default_http_arguments_as_json)
    assert not params
    assert data == default_http_arguments_as_string