author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 21 May 2010 13:34:52 +0200 | |
changeset 5562 | 4ccd599b5cf0 |
parent 5424 | 8ecbcbff9777 |
child 5609 | d247e2e06db2 |
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') |
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
|
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 |
config = TestServerConfiguration('data') |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
config.bootstrap_cubes() |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
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
|
31 |
|
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 |
class XYTC(TestCase): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
def setUp(self): |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
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
|
36 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
37 |
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
|
38 |
qi = self.tr.translate(sparql) |
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
39 |
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
|
40 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
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
|
42 |
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
|
43 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
44 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
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
|
46 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
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
|
48 |
SELECT ?project |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
?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
|
51 |
}''', '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
|
52 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
54 |
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
|
55 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
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
|
57 |
SELECT ?created |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
58 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
59 |
?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
|
60 |
doap:created ?created. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
61 |
}''', '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
|
62 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
63 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
64 |
def test_base_attr_sel_distinct(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
65 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
66 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
67 |
SELECT DISTINCT ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
68 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
69 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
70 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
71 |
}''', '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
|
72 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
73 |
|
2427
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
74 |
def test_base_attr_sel_reduced(self): |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
75 |
self._test(''' |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
76 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
77 |
SELECT REDUCED ?name |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
78 |
WHERE { |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
79 |
?project a doap:Project; |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
80 |
doap:name ?name. |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
81 |
}''', 'Any NAME WHERE PROJECT name NAME, PROJECT is Project') |
3e0ef847a546
distinct / reduced support
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2422
diff
changeset
|
82 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
83 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
84 |
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
|
85 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
86 |
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
|
87 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
88 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
89 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
90 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
91 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
92 |
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
|
93 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
94 |
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
|
95 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
96 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
97 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
98 |
doap:name ?name. |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
99 |
} |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
100 |
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
|
101 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
102 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
103 |
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
|
104 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
105 |
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
|
106 |
SELECT ?name |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
107 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
108 |
?project a doap:Project; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
109 |
doap:name ?name; |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
110 |
doap:created ?created. |
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 |
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
|
113 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
114 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
115 |
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
|
116 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
117 |
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
|
118 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
119 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
120 |
?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
|
121 |
}''', '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
|
122 |
|
2431
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_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
|
125 |
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
|
126 |
try: |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
127 |
self._test(''' |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
128 |
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
|
129 |
SELECT ?x ?cd |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
130 |
WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
131 |
?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
|
132 |
}''', '(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
|
133 |
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
|
134 |
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
|
135 |
|
2431
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
136 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
137 |
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
|
138 |
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
|
139 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
140 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
141 |
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
|
142 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
143 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
144 |
?x dc:date ?cd; |
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 |
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
|
147 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
148 |
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
|
149 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
150 |
|
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
151 |
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
|
152 |
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
|
153 |
try: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
154 |
self._test(''' |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
155 |
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
|
156 |
SELECT ?x ?cd |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
157 |
WHERE { |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
158 |
?x dc:date ?cd; |
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 |
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
|
161 |
finally: |
93c061eac647
sparql support for limit/offset/orderby
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2428
diff
changeset
|
162 |
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
|
163 |
|
2435
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
164 |
|
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
165 |
def test_restr_attr(self): |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
166 |
self._test(''' |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
167 |
PREFIX doap: <http://usefulinc.com/ns/doap#> |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
168 |
SELECT ?project |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
169 |
WHERE { |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
170 |
?project a doap:Project; |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
171 |
doap:name "cubicweb". |
85be7a811afe
sparql: support for literal restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2431
diff
changeset
|
172 |
}''', '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
|
173 |
|
2422
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
174 |
# # 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
|
175 |
# 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
|
176 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
177 |
# { :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
|
178 |
# :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
|
179 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
180 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
181 |
# 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
|
182 |
# SELECT * |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
183 |
# { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
184 |
# { ?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
|
185 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
186 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
187 |
# 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
|
188 |
# 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
|
189 |
# 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
|
190 |
# SELECT ?desc |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
191 |
# WHERE { |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
192 |
# 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
|
193 |
# dc:description ?desc. |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
194 |
# } |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
195 |
|
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
196 |
if __name__ == '__main__': |
96da7dc42eb5
quick and dirty support from simple sparql queries + base ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
197 |
unittest_main() |