-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1624 from gjhiggins/feature-prepareupdate
Feature prepareupdate
- Loading branch information
Showing
6 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
from rdflib.plugins.sparql import prepareUpdate, prepareQuery | ||
from rdflib.namespace import FOAF | ||
from rdflib import ( | ||
Graph, | ||
URIRef, | ||
) | ||
|
||
|
||
def test_prepare_update(): | ||
|
||
q = prepareUpdate( | ||
"""\ | ||
PREFIX dc: <http://purl.org/dc/elements/1.1/> | ||
INSERT DATA | ||
{ <http://example/book3> dc:title "A new book" ; | ||
dc:creator "A.N.Other" . | ||
} ; | ||
""", | ||
initNs={}, | ||
) | ||
|
||
g = Graph() | ||
g.update(q, initBindings={}) | ||
assert len(g) == 2 | ||
|
||
|
||
def test_prepare_query(): | ||
|
||
q = prepareQuery( | ||
"SELECT ?name WHERE { ?person foaf:knows/foaf:name ?name . }", | ||
initNs={"foaf": FOAF}, | ||
) | ||
|
||
g = Graph() | ||
g.parse( | ||
location=os.path.join(os.path.dirname(__file__), "..", "examples", "foaf.n3"), | ||
format="n3", | ||
) | ||
|
||
tim = URIRef("http://www.w3.org/People/Berners-Lee/card#i") | ||
|
||
assert len(list(g.query(q, initBindings={"person": tim}))) == 50 |