Ejemplo n.º 1
0
    def test_should_parse_schema_from_quoted_profile(self, get):
        headers = {
            'content-type': (
                'application/json; charset=utf-8; profile="%s"'
                % self.SCHEMA_URL)
        }
        schema.from_header(headers)

        get.assert_called_with(self.SCHEMA_URL, headers=ANY)
Ejemplo n.º 2
0
def from_response(response, auth=None):
    try:
        data = response.json()
    except ValueError:
        data = {}
    return Resource(url=response.url,
                    auth=auth,
                    data=data,
                    schema=schema.from_header(response.headers, auth),
                    response=response)
Ejemplo n.º 3
0
def from_response(response, auth=None):
    try:
        data = response.json()
    except ValueError:
        data = {}
    return Resource(
        url=response.url,
        auth=auth,
        data=data,
        schema=schema.from_header(response.headers, auth)
    )
Ejemplo n.º 4
0
def from_response(klass, response, auth=None):
    try:
        data = response.json()
    except ValueError:
        data = {}
    return klass(
        url=response.url,
        auth=auth,
        data=data,
        schema=schema.from_header(response.headers, auth),
        response=response
    )