cubicweb/test/unittest_entity.py
changeset 11290 12d226a5bab9
parent 11279 e4f11ef1face
child 11759 7b7108eb8178
equal deleted inserted replaced
11286:0b38e373b985 11290:12d226a5bab9
   317             self.assertEqual(tag.cw_related_rql('tags', 'subject', ('Personne',)),
   317             self.assertEqual(tag.cw_related_rql('tags', 'subject', ('Personne',)),
   318                              'Any X,AA,AB ORDERBY AB '
   318                              'Any X,AA,AB ORDERBY AB '
   319                              'WHERE E eid %(x)s, E tags X, X is Personne, X modification_date AA, '
   319                              'WHERE E eid %(x)s, E tags X, X is Personne, X modification_date AA, '
   320                              'X nom AB')
   320                              'X nom AB')
   321 
   321 
       
   322     def test_related_rql_sort_terms(self):
       
   323         with self.admin_access.web_request() as req:
       
   324             tag = self.vreg['etypes'].etype_class('Tag')(req)
       
   325             select = tag.cw_related_rqlst('tags', 'subject',
       
   326                                           sort_terms=(('nom', True),
       
   327                                                       ('modification_date', False)))
       
   328             expected = (
       
   329                 'Any X,AA ORDERBY AB,AA DESC '
       
   330                 'WHERE E eid %(x)s, E tags X, X modification_date AA, X nom AB')
       
   331             self.assertEqual(select.as_string(), expected)
       
   332 
   322     def test_related_rql_ambiguous_cant_use_fetch_order(self):
   333     def test_related_rql_ambiguous_cant_use_fetch_order(self):
   323         with self.admin_access.web_request() as req:
   334         with self.admin_access.web_request() as req:
   324             tag = self.vreg['etypes'].etype_class('Tag')(req)
   335             tag = self.vreg['etypes'].etype_class('Tag')(req)
   325             for ttype in self.schema['tags'].objects():
   336             for ttype in self.schema['tags'].objects():
   326                 self.vreg['etypes'].etype_class(ttype).fetch_attrs = ('modification_date',)
   337                 self.vreg['etypes'].etype_class(ttype).fetch_attrs = ('modification_date',)