diff options
| author | Drew Perttula <drewp@bigasterisk.com> | 2013-11-29 14:38:38 -0800 |
|---|---|---|
| committer | Drew Perttula <drewp@bigasterisk.com> | 2013-11-29 14:38:38 -0800 |
| commit | f0fcb5afe6e6ed0d1312f50371491a76e5e7e59d (patch) | |
| tree | 7792c1c0d0ec2676e131b38c2f4094a9f7ce76b8 /test/test_initbindings.py | |
| parent | 04fe227708ff5e658d9b8ceb86d46991b1dce5b1 (diff) | |
| download | rdflib-f0fcb5afe6e6ed0d1312f50371491a76e5e7e59d.tar.gz | |
add tests for initBindings with/without Variable and leading '?'
Diffstat (limited to 'test/test_initbindings.py')
| -rw-r--r-- | test/test_initbindings.py | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/test/test_initbindings.py b/test/test_initbindings.py index 1d1ef0b7..75923858 100644 --- a/test/test_initbindings.py +++ b/test/test_initbindings.py @@ -1,34 +1,37 @@ from nose import SkipTest -raise SkipTest('skipped - pending fix for #294') -from rdflib import ConjunctiveGraph, URIRef, Literal +from rdflib import ConjunctiveGraph, URIRef, Literal, Namespace, Variable g = ConjunctiveGraph() def testStr(): - + raise SkipTest('skipped - pending fix for #294') a = set(g.query("SELECT (STR(?target) AS ?r) WHERE { }", initBindings={'target': URIRef('example:a')})) b = set(g.query("SELECT (STR(?target) AS ?r) WHERE { } VALUES (?target) {(<example:a>)}")) assert a==b, "STR: %r != %r"%(a,b) def testIsIRI(): + raise SkipTest('skipped - pending fix for #294') a = set(g.query("SELECT (isIRI(?target) AS ?r) WHERE { }", initBindings={'target': URIRef('example:a')})) b = set(g.query("SELECT (isIRI(?target) AS ?r) WHERE { } VALUES (?target) {(<example:a>)}")) assert a==b, "isIRI: %r != %r"%(a,b) def testIsBlank(): + raise SkipTest('skipped - pending fix for #294') a = set(g.query("SELECT (isBlank(?target) AS ?r) WHERE { }", initBindings={'target': URIRef('example:a')})) b = set(g.query("SELECT (isBlank(?target) AS ?r) WHERE { } VALUES (?target) {(<example:a>)}")) assert a==b, "isBlank: %r != %r"%(a,b) def testIsLiteral(): + raise SkipTest('skipped - pending fix for #294') a = set(g.query("SELECT (isLiteral(?target) AS ?r) WHERE { }", initBindings={'target': Literal('example')})) b = set(g.query("SELECT (isLiteral(?target) AS ?r) WHERE { } VALUES (?target) {('example')}")) assert a==b, "isLiteral: %r != %r"%(a,b) def testUCase(): + raise SkipTest('skipped - pending fix for #294') a = set(g.query("SELECT (UCASE(?target) AS ?r) WHERE { }", initBindings={'target': Literal('example')})) b = set(g.query("SELECT (UCASE(?target) AS ?r) WHERE { } VALUES (?target) {('example')}")) assert a==b, "UCASE: %r != %r"%(a,b) @@ -39,6 +42,29 @@ def testNoFunc(): assert a==b, "no func: %r != %r"%(a,b) +EX = Namespace("http://example.com/") +g2 = ConjunctiveGraph() +g2.bind('', EX) +g2.add((EX['s1'], EX['p'], EX['o1'])) +g2.add((EX['s2'], EX['p'], EX['o2'])) + +def testStringKey(): + results = list(g2.query("SELECT ?o WHERE { ?s :p ?o }", initBindings={"s": EX['s1']})) + assert len(results) == 1, results + +def testStringKeyWithQuestionMark(): + results = list(g2.query("SELECT ?o WHERE { ?s :p ?o }", initBindings={"?s": EX['s1']})) + assert len(results) == 1, results + +def testVariableKey(): + results = list(g2.query("SELECT ?o WHERE { ?s :p ?o }", initBindings={Variable("s"): EX['s1']})) + assert len(results) == 1, results + +def testVariableKeyWithQuestionMark(): + results = list(g2.query("SELECT ?o WHERE { ?s :p ?o }", initBindings={Variable("?s"): EX['s1']})) + assert len(results) == 1, results + + if __name__ == "__main__": import sys |
