183 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E evaluee X, ' |
183 'Any X,AA,AB ORDERBY AA ASC WHERE E eid %(x)s, E evaluee X, ' |
184 'X type AA, X modification_date AB') |
184 'X type AA, X modification_date AB') |
185 Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', )) |
185 Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', )) |
186 # XXX |
186 # XXX |
187 self.assertEquals(p.related_rql('evaluee'), |
187 self.assertEquals(p.related_rql('evaluee'), |
188 'Any X,AA ORDERBY Z DESC WHERE X modification_date Z, E eid %(x)s, E evaluee X, X modification_date AA') |
188 'Any X,AA ORDERBY Z DESC ' |
|
189 'WHERE X modification_date Z, E eid %(x)s, E evaluee X, ' |
|
190 'X modification_date AA') |
|
191 |
|
192 tag = self.vreg['etypes'].etype_class('Tag')(self.request()) |
|
193 self.assertEquals(tag.related_rql('tags', 'subject'), |
|
194 'Any X,AA ORDERBY Z DESC ' |
|
195 'WHERE X modification_date Z, E eid %(x)s, E tags X, ' |
|
196 'X modification_date AA') |
|
197 self.assertEquals(tag.related_rql('tags', 'subject', ('Personne',)), |
|
198 'Any X,AA,AB ORDERBY AA ASC ' |
|
199 'WHERE E eid %(x)s, E tags XE is IN (Personne), X nom AA, ' |
|
200 'X modification_date AB') |
189 |
201 |
190 def test_unrelated_rql_security_1(self): |
202 def test_unrelated_rql_security_1(self): |
191 user = self.request().user |
203 user = self.request().user |
192 rql = user.unrelated_rql('use_email', 'EmailAddress', 'subject')[0] |
204 rql = user.unrelated_rql('use_email', 'EmailAddress', 'subject')[0] |
193 self.assertEquals(rql, 'Any O,AA,AB,AC ORDERBY AC DESC ' |
205 self.assertEquals(rql, 'Any O,AA,AB,AC ORDERBY AC DESC ' |
458 def test_absolute_url_empty_field(self): |
470 def test_absolute_url_empty_field(self): |
459 card = self.add_entity('Card', wikiid=u'', title=u'test') |
471 card = self.add_entity('Card', wikiid=u'', title=u'test') |
460 self.assertEquals(card.absolute_url(), |
472 self.assertEquals(card.absolute_url(), |
461 'http://testing.fr/cubicweb/card/eid/%s' % card.eid) |
473 'http://testing.fr/cubicweb/card/eid/%s' % card.eid) |
462 |
474 |
|
475 def test_create_entity(self): |
|
476 p1 = self.add_entity('Personne', nom=u'fayolle', prenom=u'alexandre') |
|
477 p2 = self.add_entity('Personne', nom=u'campeas', prenom=u'aurelien') |
|
478 note = self.add_entity('Note', type=u'z') |
|
479 req = self.request() |
|
480 p = req.create_entity('Personne', nom=u'di mascio', prenom=u'adrien', |
|
481 connait=p1, evaluee=[p1, p2], |
|
482 reverse_ecrit_par=note) |
|
483 self.assertEquals(p.nom, 'di mascio') |
|
484 self.assertEquals([c.nom for c in p.connait], ['fayolle']) |
|
485 self.assertEquals(sorted([c.nom for c in p.evaluee]), ['campeas', 'fayolle']) |
|
486 self.assertEquals([c.type for c in p.reverse_ecrit_par], ['z']) |
|
487 |
|
488 |
|
489 |
463 if __name__ == '__main__': |
490 if __name__ == '__main__': |
464 from logilab.common.testlib import unittest_main |
491 from logilab.common.testlib import unittest_main |
465 unittest_main() |
492 unittest_main() |
466 |
493 |