def test_indirect_container(self, ic_rdf): """ Create an indirect container and verify special properties. """ cont_uid = '/top_container' ic_uid = '{}/test_ic'.format(cont_uid) member_uid = '{}/ic_member'.format(ic_uid) target_uid = '/ic_target' ic_member_rdf = b''' PREFIX ore: <http://www.openarchives.org/ore/terms/> <> ore:proxyFor <info:fcres/ic_target> .''' rsrc_api.create_or_replace(cont_uid) rsrc_api.create_or_replace(target_uid) rsrc_api.create_or_replace(ic_uid, rdf_data=ic_rdf, rdf_fmt='turtle') rsrc_api.create_or_replace( member_uid, rdf_data=ic_member_rdf, rdf_fmt='turtle') ic_rsrc = rsrc_api.get(ic_uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['ldp'].Container in ic_rsrc.ldp_types assert nsc['ldp'].IndirectContainer in ic_rsrc.ldp_types assert nsc['ldp'].DirectContainer not in ic_rsrc.ldp_types member_rsrc = rsrc_api.get(member_uid) top_cont_rsrc = rsrc_api.get(cont_uid) with env.app_globals.rdf_store.txn_ctx(): assert top_cont_rsrc.imr[ top_cont_rsrc.uri: nsc['dcterms'].relation: nsc['fcres'][target_uid]]
def test_replace_rsrc(self): uid = '/test_replace' uri = nsc['fcres'][uid] gr1 = Graph().parse(data='<> a <http://ex.org/type#A> .', format='turtle', publicID=uri) evt = rsrc_api.create_or_replace(uid, graph=gr1) assert evt == RES_CREATED rsrc = rsrc_api.get(uid) assert rsrc.imr[rsrc.uri:nsc['rdf'].type:URIRef('http://ex.org/type#A' )] assert rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['ldp'].RDFSource] gr2 = Graph().parse(data='<> a <http://ex.org/type#B> .', format='turtle', publicID=uri) #pdb.set_trace() evt = rsrc_api.create_or_replace(uid, graph=gr2) assert evt == RES_UPDATED rsrc = rsrc_api.get(uid) assert not rsrc.imr[rsrc.uri:nsc['rdf']. type:URIRef('http://ex.org/type#A')] assert rsrc.imr[rsrc.uri:nsc['rdf'].type:URIRef('http://ex.org/type#B' )] assert rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['ldp'].RDFSource]
def test_replace_rsrc(self): uid = '/test_replace' uri = nsc['fcres'][uid] with env.app_globals.rdf_store.txn_ctx(): gr1 = from_rdf( data='<> a <http://ex.org/type#A> .', format='turtle', publicID=uri ) evt, _ = rsrc_api.create_or_replace(uid, graph=gr1) assert evt == RES_CREATED rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : URIRef('http://ex.org/type#A')] assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : nsc['ldp'].RDFSource] with env.app_globals.rdf_store.txn_ctx(): gr2 = from_rdf( data='<> a <http://ex.org/type#B> .', format='turtle', publicID=uri ) #pdb.set_trace() evt, _ = rsrc_api.create_or_replace(uid, graph=gr2) assert evt == RES_UPDATED rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert not rsrc.imr[ rsrc.uri : nsc['rdf'].type : URIRef('http://ex.org/type#A')] assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : URIRef('http://ex.org/type#B')] assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : nsc['ldp'].RDFSource]
def tombstone(uid): """ Handle all tombstone operations. The only allowed methods are POST and DELETE; any other verb will return a 405. """ try: rsrc_api.get(uid) except exc.TombstoneError as e: if request.method == 'DELETE': if e.uid == uid: rsrc_api.delete(uid, False) return '', 204 else: return _tombstone_response(e, uid) elif request.method == 'POST': if e.uid == uid: rsrc_uri = rsrc_api.resurrect(uid) headers = {'Location': rsrc_uri} return rsrc_uri, 201, headers else: return _tombstone_response(e, uid) else: return 'Method Not Allowed.', 405 except exc.ResourceNotExistsError as e: return str(e), 404 else: return '', 404
def test_soft_delete(self): """ Soft-delete (bury) a resource. """ uid = '/test_soft_delete01' rsrc_api.create_or_replace(uid) rsrc_api.delete(uid) with pytest.raises(TombstoneError): rsrc_api.get(uid)
def test_hard_delete(self): """ Hard-delete (forget) a resource. """ uid = '/test_hard_delete01' rsrc_api.create_or_replace(uid) rsrc_api.delete(uid, False) with pytest.raises(ResourceNotExistsError): rsrc_api.get(uid) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect(uid)
def test_resurrect_children(self): """ Resurrect a resource with its children. This uses fixtures from the previous test. """ uid = '/test_soft_delete_children01' rsrc_api.resurrect(uid) parent_rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['ldp'].Resource in parent_rsrc.ldp_types for i in range(3): child_rsrc = rsrc_api.get('{}/child{}'.format(uid, i)) with env.app_globals.rdf_store.txn_ctx(): assert nsc['ldp'].Resource in child_rsrc.ldp_types
def test_create_version(self): """ Create a version snapshot. """ uid = '/test_version1' rdf_data = b'<> <http://purl.org/dc/terms/title> "Original title." .' update_str = '''DELETE { <> <http://purl.org/dc/terms/title> "Original title." . } INSERT { <> <http://purl.org/dc/terms/title> "Title #2." . } WHERE { }''' rsrc_api.create_or_replace(uid, rdf_data=rdf_data, rdf_fmt='turtle') ver_uid = rsrc_api.create_version(uid, 'v1').split('fcr:versions/')[-1] #FIXME Without this, the test fails. #set(rsrc_api.get_version(uid, ver_uid)) rsrc_api.update(uid, update_str) current = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert ( (current.uri, nsc['dcterms'].title, Literal('Title #2.')) in current.imr) assert ( (current.uri, nsc['dcterms'].title, Literal('Original title.')) not in current.imr) v1 = rsrc_api.get_version(uid, ver_uid) with env.app_globals.rdf_store.txn_ctx(): assert ( (v1.uri, nsc['dcterms'].title, Literal('Original title.')) in set(v1)) assert ( (v1.uri, nsc['dcterms'].title, Literal('Title #2.')) not in set(v1))
def test_delta_update(self): """ Update a resource with two sets of add and remove triples. """ uid = '/test_delta_patch' uri = nsc['fcres'][uid] init_trp = { (URIRef(uri), nsc['rdf'].type, nsc['foaf'].Person), (URIRef(uri), nsc['foaf'].name, Literal('Joe Bob')), } remove_trp = { (URIRef(uri), nsc['rdf'].type, nsc['foaf'].Person), } add_trp = { (URIRef(uri), nsc['rdf'].type, nsc['foaf'].Organization), } gr = Graph() gr += init_trp rsrc_api.create_or_replace(uid, graph=gr) rsrc_api.update_delta(uid, remove_trp, add_trp) rsrc = rsrc_api.get(uid) assert rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['foaf'].Organization] assert rsrc.imr[rsrc.uri:nsc['foaf'].name:Literal('Joe Bob')] assert not rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['foaf'].Person]
def test_delta_update_wildcard(self): """ Update a resource using wildcard modifiers. """ uid = '/test_delta_patch_wc' uri = nsc['fcres'][uid] init_trp = { (URIRef(uri), nsc['rdf'].type, nsc['foaf'].Person), (URIRef(uri), nsc['foaf'].name, Literal('Joe Bob')), (URIRef(uri), nsc['foaf'].name, Literal('Joe Average Bob')), (URIRef(uri), nsc['foaf'].name, Literal('Joe 12oz Bob')), } remove_trp = { (URIRef(uri), nsc['foaf'].name, None), } add_trp = { (URIRef(uri), nsc['foaf'].name, Literal('Joan Knob')), } gr = Graph() gr += init_trp rsrc_api.create_or_replace(uid, graph=gr) rsrc_api.update_delta(uid, remove_trp, add_trp) rsrc = rsrc_api.get(uid) assert rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['foaf'].Person] assert rsrc.imr[rsrc.uri:nsc['foaf'].name:Literal('Joan Knob')] assert not rsrc.imr[rsrc.uri:nsc['foaf'].name:Literal('Joe Bob')] assert not rsrc.imr[rsrc.uri:nsc['foaf'].name:Literal('Joe Average Bob' )] assert not rsrc.imr[rsrc.uri:nsc['foaf'].name:Literal('Joe 12oz Bob')]
def test_fixity_check_corrupt(self): """ Verify that fixity check fails for a corrupted resource. """ uid = uuid4() content = uuid4().bytes path = f'/ldp/{uid}' fix_path = f'/admin/{uid}/fixity' self.client.put(path, data=content, headers={'content-type': 'text/plain'}) rsrc = rsrc_api.get(f'/{uid}') with env.app_globals.rdf_store.txn_ctx(): fname = rsrc.local_path with open(fname, 'wb') as fh: fh.write(uuid4().bytes) rsp = self.client.get(fix_path) assert rsp.status_code == 200 assert rsp.json['uid'] == f'/{uid}' assert rsp.json['pass'] == False
def test_create_child_uri_graph(self): """ Create a resource with empty string ("self") URIs in the RDF body. """ uid = '/reluri06' uri = nsc['fcres'][uid] gr = Graph() with env.app_globals.rdf_store.txn_ctx(): gr.add({ (URIRef('child1'), nsc['rdf']['type'], URIRef('urn:type:A')), ( URIRef('http://ex.org/external'), URIRef('urn:pred:x'), URIRef('child22') ) }) rsrc_api.create_or_replace(uid, graph=gr) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert rsrc.imr[ URIRef(str(uri) + '/child1'): nsc['rdf'].type: URIRef('urn:type:A')] assert rsrc.imr[ URIRef('http://ex.org/external'): URIRef('urn:pred:x'): URIRef(str(uri) + '/child2')]
def test_delete_children(self): """ Soft-delete a resource with children. """ uid = '/test_soft_delete_children01' rsrc_api.create_or_replace(uid) for i in range(3): rsrc_api.create_or_replace('{}/child{}'.format(uid, i)) rsrc_api.delete(uid) with pytest.raises(TombstoneError): rsrc_api.get(uid) for i in range(3): with pytest.raises(TombstoneError): rsrc_api.get('{}/child{}'.format(uid, i)) # Cannot resurrect children of a tombstone. with pytest.raises(TombstoneError): rsrc_api.resurrect('{}/child{}'.format(uid, i))
def get_resource(uid, out_fmt=None): r""" https://www.w3.org/TR/ldp/#ldpr-HTTP_GET Retrieve RDF or binary content. :param str uid: UID of resource to retrieve. The repository root has an empty string for UID. :param str out_fmt: Force output to RDF or non-RDF if the resource is a LDP-NR. This is not available in the API but is used e.g. by the ``\*/fcr:metadata`` and ``\*/fcr:content`` endpoints. The default is False. """ logger.info('UID: {}'.format(uid)) out_headers = std_headers repr_options = defaultdict(dict) if 'prefer' in request.headers: prefer = g.tbox.parse_rfc7240(request.headers['prefer']) logger.debug('Parsed Prefer header: {}'.format(pformat(prefer))) if 'return' in prefer: repr_options = parse_repr_options(prefer['return']) try: rsrc = rsrc_api.get(uid, repr_options) except ResourceNotExistsError as e: return str(e), 404 except TombstoneError as e: return _tombstone_response(e, uid) else: if out_fmt is None: out_fmt = ('rdf' if isinstance(rsrc, LdpRs) or is_accept_hdr_rdf_parsable() else 'non_rdf') out_headers.update(_headers_from_metadata(rsrc)) uri = g.tbox.uid_to_uri(uid) if out_fmt == 'rdf': ggr = g.tbox.globalize_graph(rsrc.out_graph) ggr.namespace_manager = nsm return _negotiate_content(ggr, out_headers, uid=uid, uri=uri) else: if not getattr(rsrc, 'local_path', False): return ('{} has no binary content.'.format(rsrc.uid), 404) logger.debug('Streaming out binary content.') rsp = make_response( send_file(rsrc.local_path, as_attachment=True, attachment_filename=rsrc.filename, mimetype=rsrc.mimetype)) logger.debug('Out headers: {}'.format(out_headers)) rsp.headers.add('Link', '<{}/fcr:metadata>; rel="describedby"'.format(uri)) for link in out_headers['Link']: rsp.headers.add('Link', link) return rsp
def test_hard_delete_children(self): """ Hard-delete (forget) a resource with its children. This uses fixtures from the previous test. """ uid = '/test_hard_delete_children01' rsrc_api.create_or_replace(uid) for i in range(3): rsrc_api.create_or_replace('{}/child{}'.format(uid, i)) rsrc_api.delete(uid, False) with pytest.raises(ResourceNotExistsError): rsrc_api.get(uid) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect(uid) for i in range(3): with pytest.raises(ResourceNotExistsError): rsrc_api.get('{}/child{}'.format(uid, i)) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect('{}/child{}'.format(uid, i))
def test_create_ldp_nr(self): """ Create a non-RDF resource (LDP-NR). """ uid = '/{}'.format(uuid4()) data = b'Hello. This is some dummy content.' rsrc_api.create_or_replace(uid, stream=BytesIO(data), mimetype='text/plain') rsrc = rsrc_api.get(uid) assert rsrc.content.read() == data
def test_resurrect(self): """ Restore (resurrect) a soft-deleted resource. """ uid = '/test_soft_delete02' rsrc_api.create_or_replace(uid) rsrc_api.delete(uid) rsrc_api.resurrect(uid) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['ldp'].Resource in rsrc.ldp_types
def test_hard_delete_descendants(self): """ Forget a resource with all its descendants. """ uid = '/test_hard_delete_descendants01' rsrc_api.create_or_replace(uid) for i in range(1, 4): rsrc_api.create_or_replace('{}/child{}'.format(uid, i)) for j in range(i): rsrc_api.create_or_replace('{}/child{}/grandchild{}'.format( uid, i, j)) rsrc_api.delete(uid, False) with pytest.raises(ResourceNotExistsError): rsrc_api.get(uid) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect(uid) for i in range(1, 4): with pytest.raises(ResourceNotExistsError): rsrc_api.get('{}/child{}'.format(uid, i)) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect('{}/child{}'.format(uid, i)) for j in range(i): with pytest.raises(ResourceNotExistsError): rsrc_api.get('{}/child{}/grandchild{}'.format( uid, i, j)) with pytest.raises(ResourceNotExistsError): rsrc_api.resurrect('{}/child{}/grandchild{}'.format( uid, i, j))
def test_get_root_node(self): """ Get the root node. The ``dcterms:title`` property should be included. """ rsrc = rsrc_api.get('/') assert isinstance(rsrc, Ldpr) gr = rsrc.imr assert len(gr) == 10 assert gr[gr.identifier:nsc['rdf'].type:nsc['ldp'].Resource] assert gr[gr.identifier:nsc['dcterms'].title:Literal('Repository Root' )]
def test_create_ldp_dc_put(self, dc_rdf): """ Create an LDP Direct Container via PUT. """ dc_uid = '/test_dc_put01' _, dc_rsrc = rsrc_api.create_or_replace( dc_uid, rdf_data=dc_rdf, rdf_fmt='turtle') member_rsrc = rsrc_api.get('/member') with env.app_globals.rdf_store.txn_ctx(): assert nsc['ldp'].Container in dc_rsrc.ldp_types assert nsc['ldp'].DirectContainer in dc_rsrc.ldp_types
def test_add_dc_member(self, dc_rdf): """ Add members to a direct container and verify special properties. """ dc_uid = '/test_dc_put02' _, dc_rsrc = rsrc_api.create_or_replace( dc_uid, rdf_data=dc_rdf, rdf_fmt='turtle') child_uid = rsrc_api.create(dc_uid).uid member_rsrc = rsrc_api.get('/member') with env.app_globals.rdf_store.txn_ctx(): assert member_rsrc.imr[ member_rsrc.uri: nsc['dcterms'].relation: nsc['fcres'][child_uid]]
def test_get_root_node(self): """ Get the root node. The ``dcterms:title`` property should be included. """ rsrc = rsrc_api.get('/') assert isinstance(rsrc, Ldpr) gr = rsrc.imr assert len(gr) == 10 with env.app_globals.rdf_store.txn_ctx(): assert gr[gr.uri : nsc['rdf'].type : nsc['ldp'].Resource ] assert gr[ gr.uri : nsc['dcterms'].title : Literal('Repository Root')]
def test_revert_to_version(self): """ Test reverting to a previous version. Uses assets from previous test. """ uid = '/test_version1' ver_uid = 'v1' rsrc_api.revert_to_version(uid, ver_uid) rev = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert ( (rev.uri, nsc['dcterms'].title, Literal('Original title.')) in rev.imr)
def get_resource(uid, force_rdf=False): ''' https://www.w3.org/TR/ldp/#ldpr-HTTP_GET Retrieve RDF or binary content. @param uid (string) UID of resource to retrieve. The repository root has an empty string for UID. @param force_rdf (boolean) Whether to retrieve RDF even if the resource is a LDP-NR. This is not available in the API but is used e.g. by the `*/fcr:metadata` endpoint. The default is False. ''' logger.info('UID: {}'.format(uid)) out_headers = std_headers repr_options = defaultdict(dict) if 'prefer' in request.headers: prefer = g.tbox.parse_rfc7240(request.headers['prefer']) logger.debug('Parsed Prefer header: {}'.format(pformat(prefer))) if 'return' in prefer: repr_options = parse_repr_options(prefer['return']) try: rsrc = rsrc_api.get(uid, repr_options) except ResourceNotExistsError as e: return str(e), 404 except TombstoneError as e: return _tombstone_response(e, uid) else: out_headers.update(_headers_from_metadata(rsrc)) if ( isinstance(rsrc, LdpRs) or is_accept_hdr_rdf_parsable() or force_rdf): gr = g.tbox.globalize_graph(rsrc.out_graph) gr.namespace_manager = nsm return _negotiate_content(gr, out_headers) else: logger.info('Streaming out binary content.') rsp = make_response(send_file( rsrc.local_path, as_attachment=True, attachment_filename=rsrc.filename, mimetype=rsrc.mimetype)) logger.debug('Out headers: {}'.format(out_headers)) uri = g.tbox.uid_to_uri(uid) rsp.headers.add('Link', '<{}/fcr:metadata>; rel="describedby"'.format(uri)) for link in out_headers['Link']: rsp.headers.add('Link', link) return rsp
def test_versioning_children(self): """ Test that children are not affected by version restoring. 1. create parent resource 2. Create child 1 3. Version parent 4. Create child 2 5. Restore parent to previous version 6. Verify that restored version still has 2 children """ uid = '/test_version_children' ver_uid = 'v1' ch1_uid = '{}/kid_a'.format(uid) ch2_uid = '{}/kid_b'.format(uid) rsrc_api.create_or_replace(uid) rsrc_api.create_or_replace(ch1_uid) ver_uid = rsrc_api.create_version(uid, ver_uid).split('fcr:versions/')[-1] rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['fcres'][ch1_uid] in rsrc.imr[ rsrc.uri : nsc['ldp'].contains] rsrc_api.create_or_replace(ch2_uid) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['fcres'][ch2_uid] in rsrc.imr[ rsrc.uri : nsc['ldp'].contains] rsrc_api.revert_to_version(uid, ver_uid) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert nsc['fcres'][ch1_uid] in rsrc.imr[ rsrc.uri : nsc['ldp'].contains] assert nsc['fcres'][ch2_uid] in rsrc.imr[ rsrc.uri : nsc['ldp'].contains]
def test_create_ldp_rs(self): """ Create an RDF resource (LDP-RS) from a provided graph. """ uid = '/rsrc_from_graph' uri = nsc['fcres'][uid] gr = Graph().parse(data='<> a <http://ex.org/type#A> .', format='turtle', publicID=uri) #pdb.set_trace() evt = rsrc_api.create_or_replace(uid, graph=gr) rsrc = rsrc_api.get(uid) assert rsrc.imr[rsrc.uri:nsc['rdf'].type:URIRef('http://ex.org/type#A' )] assert rsrc.imr[rsrc.uri:nsc['rdf'].type:nsc['ldp'].RDFSource]
def test_create_self_uri_rdf(self): """ Create a resource with empty string ("self") URIs in the RDF body. """ uid = '/reluri01' uri = nsc['fcres'][uid] data = ''' <> a <urn:type:A> . <http://ex.org/external> <urn:pred:x> <> . ''' rsrc_api.create_or_replace(uid, rdf_data=data, rdf_fmt='ttl') rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert rsrc.imr[uri: nsc['rdf']['type']: URIRef('urn:type:A')] assert rsrc.imr[ URIRef('http://ex.org/external'): URIRef('urn:pred:x'): uri]
def test_create_ldp_rs(self): """ Create an RDF resource (LDP-RS) from a provided graph. """ uid = '/rsrc_from_graph' uri = nsc['fcres'][uid] with env.app_globals.rdf_store.txn_ctx(): gr = from_rdf( data='<> a <http://ex.org/type#A> .', format='turtle', publicID=uri) evt, _ = rsrc_api.create_or_replace(uid, graph=gr) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : URIRef('http://ex.org/type#A')] assert rsrc.imr[ rsrc.uri : nsc['rdf'].type : nsc['ldp'].RDFSource]
def test_create_ldp_dc_defaults3(self): """ Create an LDP Direct Container with default values. """ dc_rdf = b''' PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX ldp: <http://www.w3.org/ns/ldp#> <> a ldp:DirectContainer . ''' dc_uid = '/test_dc_defaults3' _, dc_rsrc = rsrc_api.create_or_replace( dc_uid, rdf_data=dc_rdf, rdf_fmt='turtle') child_uid = rsrc_api.create(dc_uid, None).uid member_rsrc = rsrc_api.get(dc_uid) with env.app_globals.rdf_store.txn_ctx(): assert member_rsrc.imr[ member_rsrc.uri: nsc['ldp'].member: nsc['fcres'][child_uid]]
def test_create_self_uri_graph(self): """ Create a resource with empty string ("self") URIs in a RDFlib graph. """ uid = '/reluri02' uri = nsc['fcres'][uid] gr = Graph() with env.app_globals.rdf_store.txn_ctx(): gr.add({ (URIRef(''), nsc['rdf']['type'], URIRef('urn:type:A')), ( URIRef('http://ex.org/external'), URIRef('urn:pred:x'), URIRef('') ), }) rsrc_api.create_or_replace(uid, graph=gr) rsrc = rsrc_api.get(uid) with env.app_globals.rdf_store.txn_ctx(): assert rsrc.imr[uri: nsc['rdf']['type']: URIRef('urn:type:A')] assert rsrc.imr[ URIRef('http://ex.org/external'): URIRef('urn:pred:x'): uri]