test/unittest_entity.py
changeset 2835 04034421b072
parent 2773 b2530e3e0afb
child 2968 0e3460341023
equal deleted inserted replaced
2834:7df3494ae657 2835:04034421b072
    99 
    99 
   100     def test_related_cache_both(self):
   100     def test_related_cache_both(self):
   101         user = self.entity('Any X WHERE X eid %(x)s', {'x':self.user().eid}, 'x')
   101         user = self.entity('Any X WHERE X eid %(x)s', {'x':self.user().eid}, 'x')
   102         adeleid = self.execute('INSERT EmailAddress X: X address "toto@logilab.org", U use_email X WHERE U login "admin"')[0][0]
   102         adeleid = self.execute('INSERT EmailAddress X: X address "toto@logilab.org", U use_email X WHERE U login "admin"')[0][0]
   103         self.commit()
   103         self.commit()
   104         self.assertEquals(user._related_cache.keys(), [])
   104         self.assertEquals(user._related_cache, {})
   105         email = user.primary_email[0]
   105         email = user.primary_email[0]
   106         self.assertEquals(sorted(user._related_cache), ['primary_email_subject'])
   106         self.assertEquals(sorted(user._related_cache), ['primary_email_subject'])
   107         self.assertEquals(email._related_cache.keys(), ['primary_email_object'])
   107         self.assertEquals(email._related_cache.keys(), ['primary_email_object'])
   108         groups = user.in_group
   108         groups = user.in_group
   109         self.assertEquals(sorted(user._related_cache), ['in_group_subject', 'primary_email_subject'])
   109         self.assertEquals(sorted(user._related_cache), ['in_group_subject', 'primary_email_subject'])