Example #1
0
 def test_should_parse_schema_from_quoted_profile(self):
     headers = {
         'content-type':
         ('application/json; charset=utf-8; profile="%s"' % self.SCHEMA_URL)
     }
     url = get_profile_from_header(headers)
     self.assertEqual(url, self.SCHEMA_URL)
Example #2
0
 def test_should_parse_schema_from_quoted_profile(self):
     headers = {
         'content-type': (
             'application/json; charset=utf-8; profile="%s"'
             % self.SCHEMA_URL)
     }
     url = get_profile_from_header(headers)
     self.assertEqual(url, self.SCHEMA_URL)
Example #3
0
    def resource(self, url, **kwargs):
        response = self.request(url, **kwargs)
        schema = None

        schema_url = get_profile_from_header(response.headers)
        if schema_url is not None:
            schema = LazySchema(href=schema_url, session=self)

        return Resource.from_response(
            response=response, session=self, schema=schema)
Example #4
0
    def resource(self, url, **kwargs):
        response = self.request(url, **kwargs)
        schema = None

        schema_url = get_profile_from_header(response.headers)
        if schema_url is not None:
            schema = LazySchema(href=schema_url, session=self)

        return Resource.from_response(response=response,
                                      session=self,
                                      schema=schema)
Example #5
0
 def test_return_none_for_missing_profile(self):
     headers = {'content-type': 'application/json'}
     url = get_profile_from_header(headers)
     self.assertIs(url, None)
Example #6
0
 def test_return_none_for_missing_content_type(self):
     headers = {}
     url = get_profile_from_header(headers)
     self.assertIs(url, None)
Example #7
0
 def test_return_none_for_missing_profile(self):
     headers = {'content-type': 'application/json'}
     url = get_profile_from_header(headers)
     self.assertIs(url, None)
Example #8
0
 def test_return_none_for_missing_content_type(self):
     headers = {}
     url = get_profile_from_header(headers)
     self.assertIs(url, None)