test/unittest_entity.py
branchstable
changeset 9769 d3f8866a48f5
parent 9440 6880674c1a26
parent 9731 027bfc467a46
child 9770 112c884b2d8d
--- a/test/unittest_entity.py	Thu Jun 05 16:15:29 2014 +0200
+++ b/test/unittest_entity.py	Tue Jun 10 09:35:26 2014 +0200
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -44,6 +44,18 @@
         for cls in self.vreg['etypes'].iter_classes():
             cls.fetch_attrs, cls.cw_fetch_order = self.backup_dict[cls]
 
+    def test_no_prefill_related_cache_bug(self):
+        session = self.session
+        usine = session.create_entity('Usine', lieu=u'Montbeliard')
+        produit = session.create_entity('Produit')
+        # usine was prefilled in glob_add_entity
+        # let's simulate produit creation without prefill
+        produit._cw_related_cache.clear()
+        # use add_relations
+        session.add_relations([('fabrique_par', [(produit.eid, usine.eid)])])
+        self.assertEqual(1, len(usine.reverse_fabrique_par))
+        self.assertEqual(1, len(produit.fabrique_par))
+
     def test_boolean_value(self):
         e = self.vreg['etypes'].etype_class('CWUser')(self.request())
         self.assertTrue(e)