ext/test/unittest_rest.py
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 10 Dec 2015 16:58:45 +0100
changeset 10997 da712d3f0601
parent 10960 9e64fddebc89
permissions -rw-r--r--
Bring back the separate web-side entity cache Prior to changeset 635cfac73d28 "[repoapi] fold ClientConnection into Connection", we had two entity caches: one on the client/dbapi/web side, and one on the server/repo side. This is a waste, but it is actually needed as long as we have the magic _cw attribute on entities which must sometimes be a request and sometimes a cnx. Removing the duplication caused weird problems with entity._cw alternating between both types of objects, which is unexpected by both the repo and the web sides. We add an entity cache on ConnectionCubicWebRequestBase, separate from the Connection's, and bring back the _cw_update_attr_cache/dont-cache-attrs mechanism, to let the server/edition code let caches know which attributes have been modified Entity.as_rset can be cached again, as ResultSet no longer modifies the entity when fetching it from a cache. Contrary to the pre-3.21 code, _cw_update_attr_cache now handles web requests and connections in the same way (otherwise the cache ends up with wrong values if a hook modifies attributes), but dont-cache-attrs is never set for (inlined) relations. Closes #6863543
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
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: 4252
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
10754
03aa9f2a4ecb [ext/test] fix test relying on repr(text)
Julien Cristau <julien.cristau@logilab.fr>
parents: 10662
diff changeset
    18
from six import PY3
03aa9f2a4ecb [ext/test] fix test relying on repr(text)
Julien Cristau <julien.cristau@logilab.fr>
parents: 10662
diff changeset
    19
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
from logilab.common.testlib import unittest_main
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    21
from cubicweb.devtools.testlib import CubicWebTC
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
1643
59c5cec05bbd move card role to cubes.card
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    23
from cubicweb.ext.rest import rest_publish
59c5cec05bbd move card role to cubes.card
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    24
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    25
class RestTC(CubicWebTC):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    26
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    27
    def context(self, req):
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    28
        return req.execute('CWUser X WHERE X login "admin"').get_entity(0, 0)
1643
59c5cec05bbd move card role to cubes.card
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    29
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    def test_eid_role(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    31
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    32
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    33
            self.assertEqual(rest_publish(context, ':eid:`%s`' % context.eid),
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    34
                             '<p><a class="reference" href="http://testing.fr/cubicweb/cwuser/admin">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    35
                             '#%s</a></p>\n' % context.eid)
10953
8b8193046600 [rest] a bit of pep8
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10952
diff changeset
    36
            self.assertEqual(rest_publish(context, ':eid:`%s:some text`' % context.eid),
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    37
                             '<p><a class="reference" href="http://testing.fr/cubicweb/cwuser/admin">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    38
                             'some text</a></p>\n')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
    def test_bad_rest_no_crash(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    41
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    42
            rest_publish(self.context(req), '''
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
| card | implication     |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
--------------------------
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
| 1-1  | N1 = N2         |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
| 1-?  | N1 <= N2        |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
| 1-+  | N1 >= N2        |
1643
59c5cec05bbd move card role to cubes.card
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    48
| 1-*  | N1>0 => N2>0    |
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
--------------------------
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
| ?-?  | N1 # N2         |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
| ?-+  | N1 >= N2        |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
| ?-*  | N1 #  N2        |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    53
--------------------------
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
| +-+  | N1>0 => N2>0 et |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
|      | N2>0 => N1>0    |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
| +-*  | N1>+ => N2>0    |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
--------------------------
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
| *-*  | N1#N2           |
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
--------------------------
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
''')
1643
59c5cec05bbd move card role to cubes.card
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    62
10952
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    63
    def test_disable_field_name_colspan(self):
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    64
        with self.admin_access.web_request() as req:
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    65
            context = self.context(req)
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    66
            value = rest_publish(context, '''my field list:
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    67
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    68
:a long dumb param name: value
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    69
''')
4f28cb25b6c1 [rest] avoid field on two lines if name is above some size limit. Closes #8961835
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9856
diff changeset
    70
            self.assertNotIn('colspan', value)
6938
6c1a960735f5 add a rql directive to restructuredtext
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6340
diff changeset
    71
6c1a960735f5 add a rql directive to restructuredtext
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6340
diff changeset
    72
    def test_rql_role_with_vid(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    73
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    74
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    75
            out = rest_publish(context, ':rql:`Any X WHERE X is CWUser:table`')
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    76
            self.assertTrue(out.endswith('<a href="http://testing.fr/cubicweb/cwuser/anon" '
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    77
                                         'title="">anon</a></td></tr>\n</tbody></table>'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    78
                                         '</div></p>\n'))
6938
6c1a960735f5 add a rql directive to restructuredtext
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6340
diff changeset
    79
7732
5430d0db52ab [web] rql directive breaks if explicit vid and empty rset (closes #1893433)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6938
diff changeset
    80
    def test_rql_role_with_vid_empty_rset(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    81
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    82
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    83
            out = rest_publish(context, ':rql:`Any X WHERE X is CWUser, X login "nono":table`')
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    84
            self.assertTrue(out.endswith('<p><div class="searchMessage"><strong>'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    85
                                         'No result matching query</strong></div>\n</p>\n'))
7732
5430d0db52ab [web] rql directive breaks if explicit vid and empty rset (closes #1893433)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6938
diff changeset
    86
5430d0db52ab [web] rql directive breaks if explicit vid and empty rset (closes #1893433)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6938
diff changeset
    87
    def test_rql_role_with_unknown_vid(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    88
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    89
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    90
            out = rest_publish(context, ':rql:`Any X WHERE X is CWUser:toto`')
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    91
            self.assertTrue(out.startswith("<p>an error occurred while interpreting this "
10754
03aa9f2a4ecb [ext/test] fix test relying on repr(text)
Julien Cristau <julien.cristau@logilab.fr>
parents: 10662
diff changeset
    92
                                           "rql directive: ObjectNotFound(%s'toto',)</p>" %
03aa9f2a4ecb [ext/test] fix test relying on repr(text)
Julien Cristau <julien.cristau@logilab.fr>
parents: 10662
diff changeset
    93
                                           ('' if PY3 else 'u')),
03aa9f2a4ecb [ext/test] fix test relying on repr(text)
Julien Cristau <julien.cristau@logilab.fr>
parents: 10662
diff changeset
    94
                            out)
7732
5430d0db52ab [web] rql directive breaks if explicit vid and empty rset (closes #1893433)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6938
diff changeset
    95
6938
6c1a960735f5 add a rql directive to restructuredtext
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6340
diff changeset
    96
    def test_rql_role_without_vid(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    97
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    98
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
    99
            out = rest_publish(context, ':rql:`Any X WHERE X is CWUser`')
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   100
            self.assertEqual(out, u'<p><h1>CWUser_plural</h1><div class="section">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   101
                             '<a href="http://testing.fr/cubicweb/cwuser/admin" title="">admin</a>'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   102
                             '</div><div class="section">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   103
                             '<a href="http://testing.fr/cubicweb/cwuser/anon" title="">anon</a>'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   104
                             '</div></p>\n')
6938
6c1a960735f5 add a rql directive to restructuredtext
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6340
diff changeset
   105
8852
59a29405688c [ext/rest] add directive bookmark to rest (closes #2545595)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8255
diff changeset
   106
    def test_bookmark_role(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   107
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   108
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   109
            rset = req.execute('INSERT Bookmark X: X title "hello", X path '
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   110
                               '"/view?rql=Any X WHERE X is CWUser"')
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   111
            eid = rset[0][0]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   112
            out = rest_publish(context, ':bookmark:`%s`' % eid)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   113
            self.assertEqual(out, u'<p><h1>CWUser_plural</h1><div class="section">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   114
                             '<a href="http://testing.fr/cubicweb/cwuser/admin" title="">admin'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   115
                             '</a></div><div class="section">'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   116
                             '<a href="http://testing.fr/cubicweb/cwuser/anon" title="">anon'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   117
                             '</a></div></p>\n')
8852
59a29405688c [ext/rest] add directive bookmark to rest (closes #2545595)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8255
diff changeset
   118
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   119
    def test_rqltable_nocontent(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   120
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   121
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   122
            out = rest_publish(context, """.. rql-table::""")
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   123
            self.assertIn("System Message: ERROR", out)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   124
            self.assertIn("Content block expected for the &quot;rql-table&quot; "
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   125
                          "directive; none found" , out)
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   126
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   127
    def test_rqltable_norset(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   128
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   129
            context = self.context(req)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   130
            rql = "Any X WHERE X is CWUser, X firstname 'franky'"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   131
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   132
                context, """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   133
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   134
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   135
                %(rql)s""" % {'rql': rql})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   136
            self.assertIn("System Message: WARNING", out)
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   137
            self.assertIn("empty result set", out)
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   138
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   139
    def test_rqltable_nooptions(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   140
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   141
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   142
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   143
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   144
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   145
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   146
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   147
                """ % {'rql': rql})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   148
            view = self.vreg['views'].select('table', req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   149
            self.assertEqual(view.render(w=None)[49:], out[49:])
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   150
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   151
    def test_rqltable_vid(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   152
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   153
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   154
            vid = 'mytable'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   155
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   156
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   157
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   158
   :vid: %(vid)s
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   159
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   160
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   161
                """ % {'rql': rql, 'vid': vid})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   162
            view = self.vreg['views'].select(vid, req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   163
            self.assertEqual(view.render(w=None)[49:], out[49:])
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   164
            self.assertIn(vid, out[:49])
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   165
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   166
    def test_rqltable_badvid(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   167
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   168
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   169
            vid = 'mytabel'
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   170
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   171
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   172
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   173
   :vid: %(vid)s
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   174
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   175
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   176
                """ % {'rql': rql, 'vid': vid})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   177
            self.assertIn("fail to select '%s' view" % vid, out)
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   178
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   179
    def test_rqltable_headers(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   180
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   181
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   182
            headers = ["nom", "prenom", "identifiant"]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   183
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   184
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   185
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   186
   :headers: %(headers)s
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   187
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   188
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   189
                """ % {'rql': rql, 'headers': ', '.join(headers)})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   190
            view = self.vreg['views'].select('table', req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   191
            view.headers = headers
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   192
            self.assertEqual(view.render(w=None)[49:], out[49:])
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   193
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   194
    def test_rqltable_headers_missing(self):
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   195
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   196
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   197
            headers = ["nom", "", "identifiant"]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   198
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   199
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   200
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   201
   :headers: %(headers)s
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   202
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   203
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   204
                """ % {'rql': rql, 'headers': ', '.join(headers)})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   205
            view = self.vreg['views'].select('table', req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   206
            view.headers = [headers[0], None, headers[2]]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   207
            self.assertEqual(view.render(w=None)[49:], out[49:])
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   208
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   209
    def test_rqltable_headers_missing_edges(self):
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   210
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   211
            rql = "Any S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   212
            headers = [" ", "prenom", ""]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   213
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   214
                self.context(req), """\
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   215
.. rql-table::
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   216
   :headers: %(headers)s
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   217
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   218
   %(rql)s
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   219
                """ % {'rql': rql, 'headers': ', '.join(headers)})
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   220
            view = self.vreg['views'].select('table', req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   221
            view.headers = [None, headers[1], None]
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   222
            self.assertEqual(view.render(w=None)[49:], out[49:])
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   223
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   224
    def test_rqltable_colvids(self):
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   225
        with self.admin_access.web_request() as req:
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   226
            rql = "Any X,S,F,L WHERE X is CWUser, X surname S, X firstname F, X login L"
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   227
            colvids = {0: "oneline"}
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   228
            out = rest_publish(
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   229
                self.context(req), """\
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   230
.. rql-table::
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   231
   :colvids: %(colvids)s
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   232
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   233
   %(rql)s
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   234
                """ % {'rql': rql,
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   235
                       'colvids': ', '.join(["%d=%s" % (k, v)
10662
10942ed172de [py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents: 9856
diff changeset
   236
                                             for k, v in colvids.items()])
9856
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   237
                   })
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   238
            view = self.vreg['views'].select('table', req, rset=req.execute(rql))
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   239
            view.cellvids = colvids
156a3fb4a884 [exttests/rest] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9517
diff changeset
   240
            self.assertEqual(view.render(w=None)[49:], out[49:])
9322
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   241
2dae5bf5ea68 [ReST] Implement a rql-table reST directive. Closes #3252856
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 8852
diff changeset
   242
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   243
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   244
    unittest_main()