Exemplo n.º 1
0
 def test_get_annotation_as_html(self):
     response = test_insert_anotation(self,
                       http_accept='application/rdf+xml', 
                       content_type='text/turtle', 
                       data=turtle_usecase1)        
     
     anno_uri = extract_annotation_uri(response.content)
     annoid = anno_uri[anno_uri.rfind('/') + 1 : ]
     
     request = _prepare_get(self.factory, '/resource/%s' % annoid)
     request.META['HTTP_ACCEPT'] = "text/html"
     response = process_resource(request, resource_id = annoid)
     self.assert_(response.status_code == 303, 
                  "HTTPResponse has status_code: %s" % response.status_code)
     
     location = response._headers.get('location', ('Location', None))[1]
     self.assert_('/page' in location, "Wrong 303 to %s" % location)
     
     request = _prepare_get(self.factory, location)
     request.META['HTTP_ACCEPT'] = "text/html"
     response = process_page(request, resource_id = annoid)
     
     
     self.assert_(response.status_code == 200, "HTTPResponse has status_code: %s" % response.status_code)
     print response
     return response
Exemplo n.º 2
0
    def test_get_annotation_as_jsonld(self):
        response = test_insert_anotation(self,
                          http_accept=FORMAT_MAP['xml'], 
                          content_type=FORMAT_MAP['turtle'], 
                          data=turtle_usecase1)                
        
        anno_uri = extract_annotation_uri(response.content)
        annoid = anno_uri[anno_uri.rfind('/') + 1 : ]
        
        request = _prepare_get(self.factory, '/resource/%s' % annoid)
        request.META['HTTP_ACCEPT'] = FORMAT_MAP['json-ld']
        response = process_resource(request, resource_id = annoid)        
        self.assert_(response.status_code == 303, "HTTPResponse has status_code: %s" % response.status_code)

        location = response._headers.get('location', ('Location', None))[1]
        self.assert_('/data' in location, "Wrong 303 to %s" % location)

        request = _prepare_get(self.factory, location)
        request.META['HTTP_ACCEPT'] = FORMAT_MAP['json-ld']
        response = process_data(request, resource_id = annoid)
        print response
        return response