diff options
author | Graham Higgins <gjh-github@bel-epa.com> | 2013-03-21 17:28:03 +0000 |
---|---|---|
committer | Graham Higgins <gjh-github@bel-epa.com> | 2013-03-21 17:28:08 +0000 |
commit | 7f6c9e73c2b7b84fd38811b3064e3740f96d7976 (patch) | |
tree | e816a4cac72b6be785ac8b8cb15253d838abf9d5 /test/test_evaluate_bind.py | |
parent | 38dcfbf91562f439f4e4bc054e706c40d14e3062 (diff) | |
download | rdflib-7f6c9e73c2b7b84fd38811b3064e3740f96d7976.tar.gz |
Immigrate rdflib-sparql (plus some prefiguring changes)
Diffstat (limited to 'test/test_evaluate_bind.py')
-rw-r--r-- | test/test_evaluate_bind.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_evaluate_bind.py b/test/test_evaluate_bind.py new file mode 100644 index 00000000..8f3a4678 --- /dev/null +++ b/test/test_evaluate_bind.py @@ -0,0 +1,28 @@ +""" +Verify evaluation of BIND expressions of different types. See +<http://www.w3.org/TR/sparql11-query/#rExpression>. +""" +from rdflib import Graph, URIRef, Literal, Variable +from rdflib.plugins.sparql.processor import SPARQLProcessor + + +def test_bind(): + base = "http://example.org/" + g = Graph() + g.add((URIRef( + base + "thing"), URIRef(base + "ns#comment"), Literal("anything"))) + s = SPARQLProcessor(g) + + def check(expr, var, obj): + r = s.query(""" + prefix : <http://example.org/ns#> + select * where { ?s ?p ?o . %s } """ % expr) + assert r['bindings'][0][Variable(var)] == obj + + yield (check, 'bind("thing" as ?name)', 'name', Literal("thing")) + + yield (check, 'bind(<http://example.org/other> as ?other)', 'other', + URIRef("http://example.org/other")) + + yield (check, "bind(:Thing as ?type)", 'type', + URIRef("http://example.org/ns#Thing")) |