author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 19 Sep 2011 14:22:28 +0200 | |
changeset 7808 | d90338624ea0 |
parent 6340 | 470d8e828fda |
child 10452 | f3dec653a27d |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2435
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
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
|
19 |
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
|
20 |
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
|
21 |
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
|
22 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
xy.add_equivalence('Project name', 'doap:Project doap:name') |
5610
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
26 |
xy.add_equivalence('Project name', 'doap:Project dc:title') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
config = TestServerConfiguration('data') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
config.bootstrap_cubes() |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
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
|
32 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
class XYTC(TestCase): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
def setUp(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
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
|
37 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
38 |
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
|
39 |
qi = self.tr.translate(sparql) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5613
diff
changeset
|
40 |
self.assertEqual(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
|
41 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
45 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
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
|
47 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
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
|
49 |
SELECT ?project |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
?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
|
52 |
}''', '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
|
53 |
|
5609
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
54 |
def test_base_rdftype(self): |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
55 |
self._test(''' |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
56 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
57 |
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
58 |
SELECT ?project |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
59 |
WHERE { |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
60 |
?project rdf:type doap:Project. |
d247e2e06db2
[sparql] adding test for "rdf:type -> is"
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
61 |
}''', 'Any PROJECT WHERE PROJECT is Project') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
62 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
63 |
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
|
64 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
65 |
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
|
66 |
SELECT ?created |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
67 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
68 |
?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
|
69 |
doap:created ?created. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
70 |
}''', '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
|
71 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
72 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
73 |
def test_base_attr_sel_distinct(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
74 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
75 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
76 |
SELECT DISTINCT ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
77 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
78 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
79 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
80 |
}''', '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
|
81 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
82 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
83 |
def test_base_attr_sel_reduced(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
84 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
85 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
86 |
SELECT REDUCED ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
87 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
88 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
89 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
90 |
}''', 'Any NAME WHERE PROJECT name NAME, PROJECT is Project') |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
91 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
92 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
93 |
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
|
94 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
95 |
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
|
96 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
97 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
98 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
99 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
100 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
101 |
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
|
102 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
103 |
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
|
104 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
105 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
106 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
107 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
108 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
109 |
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
|
110 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
111 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
112 |
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
|
113 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
114 |
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
|
115 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
116 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
117 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
118 |
doap:name ?name; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
119 |
doap:created ?created. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
120 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
121 |
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
|
122 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
123 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
124 |
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
|
125 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
126 |
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
|
127 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
128 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
129 |
?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
|
130 |
}''', '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
|
131 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
132 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
133 |
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
|
134 |
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
|
135 |
try: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
136 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
137 |
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
|
138 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
139 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
140 |
?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
|
141 |
}''', '(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
|
142 |
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
|
143 |
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
|
144 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
145 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
149 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
150 |
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
|
151 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
152 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
153 |
?x dc:date ?cd; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
154 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
155 |
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
|
156 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
157 |
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
|
158 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
159 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
160 |
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
|
161 |
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
|
162 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
163 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
164 |
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
|
165 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
166 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
167 |
?x dc:date ?cd; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
168 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
169 |
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
|
170 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
171 |
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
|
172 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
173 |
|
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
174 |
def test_restr_attr(self): |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
175 |
self._test(''' |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
176 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
177 |
SELECT ?project |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
178 |
WHERE { |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
179 |
?project a doap:Project; |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
180 |
doap:name "cubicweb". |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
181 |
}''', '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
|
182 |
|
5610
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
183 |
def test_dctitle_both_project_cwuser(self): |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
184 |
self._test(''' |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
185 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
186 |
PREFIX dc: <http://purl.org/dc/elements/1.1/> |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
187 |
SELECT ?project ?title |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
188 |
WHERE { |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
189 |
?project a doap:Project; |
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
190 |
dc:title ?title. |
5613
bc0ebfbf5c5d
[sparql] fix type inference (test_dctitle_both_project_cwuser) and support for <http://www.w3.org/1999/02/22-rdf-syntax-ns#type tag (test_base_rdftype)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5610
diff
changeset
|
191 |
}''', 'Any PROJECT, TITLE WHERE PROJECT name TITLE, PROJECT is Project') |
5610
91b0f118328a
[sparql] add failing test for two entities with dc:title
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5609
diff
changeset
|
192 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
193 |
# # 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
|
194 |
# 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
|
195 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
196 |
# { :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
|
197 |
# :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
|
198 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
199 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
200 |
# 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
|
201 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
202 |
# { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
203 |
# { ?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
|
204 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
205 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
206 |
# 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
|
207 |
# 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
|
208 |
# 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
|
209 |
# SELECT ?desc |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
210 |
# WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
211 |
# 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
|
212 |
# dc:description ?desc. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
213 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
214 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
215 |
if __name__ == '__main__': |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
216 |
unittest_main() |