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
def test_advance_status_wrong_body(self): new_state = 'stable' response = test_insert_anotation(self) anno_uri = extract_annotation_uri(response.content) annoid = anno_uri[anno_uri.rfind('/') + 1 : ] self.assertIsNotNone(annoid, "Did not insert the annotation") data = {'annotation': annoid, 'toState': new_state} response = advance_status(test_advance_status(self, url='/advance_status?' + urlencode(data), data=json.dumps(data)))
def test_advance_status(self): new_state = 'stable' response = test_insert_anotation(self) anno_uri = extract_annotation_uri(response.content) annoid = anno_uri[anno_uri.rfind('/') + 1 : ] self.assertIsNotNone(annoid, "Did not insert the annotation") data = {'annotation': annoid, 'toState': new_state} response = advance_status(test_advance_status(self, json.dumps(data))) ''' Need to verify better the triple has been moved for example using the (TBD) ''' self.assert_(response.status_code == 200, "HTTPResponse has status_code: %s" % response.status_code)
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