test/unittest_rset.py
changeset 9582 46ed25d38fe2
parent 9347 bd841d6ae723
child 9656 19c423d9d215
equal deleted inserted replaced
9581:cbf4846d408a 9582:46ed25d38fe2
   273         self.assert_(rqlst1 is rqlst2)
   273         self.assert_(rqlst1 is rqlst2)
   274 
   274 
   275     def test_get_entity_simple(self):
   275     def test_get_entity_simple(self):
   276         self.request().create_entity('CWUser', login=u'adim', upassword='adim',
   276         self.request().create_entity('CWUser', login=u'adim', upassword='adim',
   277                                      surname=u'di mascio', firstname=u'adrien')
   277                                      surname=u'di mascio', firstname=u'adrien')
       
   278         self.cnx.drop_entity_cache()
   278         e = self.execute('Any X,T WHERE X login "adim", X surname T').get_entity(0, 0)
   279         e = self.execute('Any X,T WHERE X login "adim", X surname T').get_entity(0, 0)
   279         self.assertEqual(e.cw_attr_cache['surname'], 'di mascio')
   280         self.assertEqual(e.cw_attr_cache['surname'], 'di mascio')
   280         self.assertRaises(KeyError, e.cw_attr_cache.__getitem__, 'firstname')
   281         self.assertRaises(KeyError, e.cw_attr_cache.__getitem__, 'firstname')
   281         self.assertRaises(KeyError, e.cw_attr_cache.__getitem__, 'creation_date')
   282         self.assertRaises(KeyError, e.cw_attr_cache.__getitem__, 'creation_date')
   282         self.assertEqual(pprelcachedict(e._cw_related_cache), [])
   283         self.assertEqual(pprelcachedict(e._cw_related_cache), [])
   284         self.assertEqual(e.cw_attr_cache['firstname'], 'adrien')
   285         self.assertEqual(e.cw_attr_cache['firstname'], 'adrien')
   285         self.assertEqual(pprelcachedict(e._cw_related_cache), [])
   286         self.assertEqual(pprelcachedict(e._cw_related_cache), [])
   286 
   287 
   287     def test_get_entity_advanced(self):
   288     def test_get_entity_advanced(self):
   288         self.request().create_entity('Bookmark', title=u'zou', path=u'/view')
   289         self.request().create_entity('Bookmark', title=u'zou', path=u'/view')
       
   290         self.cnx.drop_entity_cache()
   289         self.execute('SET X bookmarked_by Y WHERE X is Bookmark, Y login "anon"')
   291         self.execute('SET X bookmarked_by Y WHERE X is Bookmark, Y login "anon"')
   290         rset = self.execute('Any X,Y,XT,YN WHERE X bookmarked_by Y, X title XT, Y login YN')
   292         rset = self.execute('Any X,Y,XT,YN WHERE X bookmarked_by Y, X title XT, Y login YN')
   291 
   293 
   292         e = rset.get_entity(0, 0)
   294         e = rset.get_entity(0, 0)
   293         self.assertEqual(e.cw_row, 0)
   295         self.assertEqual(e.cw_row, 0)
   355         self.assertEqual(cached.rowcount, 0)
   357         self.assertEqual(cached.rowcount, 0)
   356 
   358 
   357 
   359 
   358     def test_get_entity_union(self):
   360     def test_get_entity_union(self):
   359         e = self.request().create_entity('Bookmark', title=u'manger', path=u'path')
   361         e = self.request().create_entity('Bookmark', title=u'manger', path=u'path')
       
   362         self.cnx.drop_entity_cache()
   360         rset = self.execute('Any X,N ORDERBY N WITH X,N BEING '
   363         rset = self.execute('Any X,N ORDERBY N WITH X,N BEING '
   361                             '((Any X,N WHERE X is Bookmark, X title N)'
   364                             '((Any X,N WHERE X is Bookmark, X title N)'
   362                             ' UNION '
   365                             ' UNION '
   363                             ' (Any X,N WHERE X is CWGroup, X name N))')
   366                             ' (Any X,N WHERE X is CWGroup, X name N))')
   364         expected = (('CWGroup', 'guests'), ('CWGroup', 'managers'),
   367         expected = (('CWGroup', 'guests'), ('CWGroup', 'managers'),