author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 15 Oct 2009 20:29:21 +0200 | |
branch | stable |
changeset 3689 | deb13e88e037 |
parent 2435 | 85be7a811afe |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
from logilab.common.testlib import TestCase, unittest_main |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
from cubicweb.devtools import TestServerConfiguration |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
from cubicweb.xy import xy |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
from cubicweb.spa2rql import Sparql2rqlTranslator |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
xy.add_equivalence('Project', 'doap:Project') |
2428
a3e10e6a2461
use space as separator, dot may be found in xml ns
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2427
diff
changeset
|
7 |
xy.add_equivalence('Project creation_date', 'doap:Project doap:created') |
a3e10e6a2461
use space as separator, dot may be found in xml ns
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2427
diff
changeset
|
8 |
xy.add_equivalence('Project name', 'doap:Project doap:name') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
config = TestServerConfiguration('data') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
config.bootstrap_cubes() |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
schema = config.load_schema() |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
class XYTC(TestCase): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
def setUp(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
self.tr = Sparql2rqlTranslator(schema) |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
20 |
def _test(self, sparql, rql, args={}): |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
qi = self.tr.translate(sparql) |
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
22 |
self.assertEquals(qi.finalize(), (rql, args)) |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
def XXX_test_base_01(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
self._test('SELECT * WHERE { }', 'Any X') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
27 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
def test_base_is(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
SELECT ?project |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
?project a doap:Project; |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
}''', 'Any PROJECT WHERE PROJECT is Project') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
def test_base_attr_sel(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
SELECT ?created |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
?project a doap:Project; |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
doap:created ?created. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
}''', 'Any CREATED WHERE PROJECT creation_date CREATED, PROJECT is Project') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
46 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
47 |
def test_base_attr_sel_distinct(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
48 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
49 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
50 |
SELECT DISTINCT ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
51 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
52 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
53 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
54 |
}''', 'DISTINCT Any NAME WHERE PROJECT name NAME, PROJECT is Project') |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
55 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
56 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
57 |
def test_base_attr_sel_reduced(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
58 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
59 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
60 |
SELECT REDUCED ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
61 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
62 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
63 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
64 |
}''', 'Any NAME WHERE PROJECT name NAME, PROJECT is Project') |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
65 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
66 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
67 |
def test_base_attr_sel_limit_offset(self): |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
68 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
69 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
70 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
71 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
72 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
73 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
74 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
75 |
LIMIT 20''', 'Any NAME LIMIT 20 WHERE PROJECT name NAME, PROJECT is Project') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
76 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
77 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
78 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
79 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
80 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
81 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
82 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
83 |
LIMIT 20 OFFSET 10''', 'Any NAME LIMIT 20 OFFSET 10 WHERE PROJECT name NAME, PROJECT is Project') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
84 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
85 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
86 |
def test_base_attr_sel_orderby(self): |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
87 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
88 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
89 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
90 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
91 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
92 |
doap:name ?name; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
93 |
doap:created ?created. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
94 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
95 |
ORDER BY ?name DESC(?created)''', 'Any NAME ORDERBY NAME ASC, CREATED DESC WHERE PROJECT name NAME, PROJECT creation_date CREATED, PROJECT is Project') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
96 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
97 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
98 |
def test_base_any_attr_sel(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
99 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
100 |
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
101 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
102 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
103 |
?x dc:date ?cd; |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
104 |
}''', 'Any X, CD WHERE X creation_date CD') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
105 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
106 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
107 |
def test_base_any_attr_sel_amb(self): |
2428
a3e10e6a2461
use space as separator, dot may be found in xml ns
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2427
diff
changeset
|
108 |
xy.add_equivalence('Version publication_date', 'doap:Version dc:date') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
109 |
try: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
110 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
111 |
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
112 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
113 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
114 |
?x dc:date ?cd; |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
115 |
}''', '(Any X, CD WHERE , X creation_date CD) UNION (Any X, CD WHERE , X publication_date CD, X is Version)') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
116 |
finally: |
2428
a3e10e6a2461
use space as separator, dot may be found in xml ns
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2427
diff
changeset
|
117 |
xy.remove_equivalence('Version publication_date', 'doap:Version dc:date') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
118 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
119 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
120 |
def test_base_any_attr_sel_amb_limit_offset(self): |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
121 |
xy.add_equivalence('Version publication_date', 'doap:Version dc:date') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
122 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
123 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
124 |
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
125 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
126 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
127 |
?x dc:date ?cd; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
128 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
129 |
LIMIT 20 OFFSET 10''', 'Any X, CD LIMIT 20 OFFSET 10 WITH X, CD BEING ((Any X, CD WHERE , X creation_date CD) UNION (Any X, CD WHERE , X publication_date CD, X is Version))') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
130 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
131 |
xy.remove_equivalence('Version publication_date', 'doap:Version dc:date') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
132 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
133 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
134 |
def test_base_any_attr_sel_amb_orderby(self): |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
135 |
xy.add_equivalence('Version publication_date', 'doap:Version dc:date') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
136 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
137 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
138 |
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
139 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
140 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
141 |
?x dc:date ?cd; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
142 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
143 |
ORDER BY DESC(?cd)''', 'Any X, CD ORDERBY CD DESC WITH X, CD BEING ((Any X, CD WHERE , X creation_date CD) UNION (Any X, CD WHERE , X publication_date CD, X is Version))') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
144 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
145 |
xy.remove_equivalence('Version publication_date', 'doap:Version dc:date') |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
146 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
147 |
|
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
148 |
def test_restr_attr(self): |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
149 |
self._test(''' |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
150 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
151 |
SELECT ?project |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
152 |
WHERE { |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
153 |
?project a doap:Project; |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
154 |
doap:name "cubicweb". |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
155 |
}''', 'Any PROJECT WHERE PROJECT name %(a)s, PROJECT is Project', {'a': 'cubicweb'}) |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
156 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
157 |
# # Two elements in the group |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
158 |
# PREFIX : <http://example.org/ns#> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
159 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
160 |
# { :p :q :r OPTIONAL { :a :b :c } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
161 |
# :p :q :r OPTIONAL { :a :b :c } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
162 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
163 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
164 |
# PREFIX : <http://example.org/ns#> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
165 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
166 |
# { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
167 |
# { ?s ?p ?o } UNION { ?a ?b ?c } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
168 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
169 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
170 |
# PREFIX dob: <http://placetime.com/interval/gregorian/1977-01-18T04:00:00Z/P> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
171 |
# PREFIX time: <http://www.ai.sri.com/daml/ontologies/time/Time.daml#> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
172 |
# PREFIX dc: <http://purl.org/dc/elements/1.1/> |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
173 |
# SELECT ?desc |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
174 |
# WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
175 |
# dob:1D a time:ProperInterval; |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
176 |
# dc:description ?desc. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
177 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
178 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
179 |
if __name__ == '__main__': |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
180 |
unittest_main() |