server/test/unittest_repository.py
changeset 7514 32081892850e
parent 7484 45a350d6b22f
parent 7513 8f4422391e5a
child 7539 7cd9fc2adcac
--- a/server/test/unittest_repository.py	Sat Jun 11 09:22:25 2011 +0200
+++ b/server/test/unittest_repository.py	Wed Jun 15 17:16:19 2011 +0200
@@ -847,6 +847,29 @@
         t1 = time.time()
         self.info('add relations (inlined): %.2gs', t1-t0)
 
+    def test_optional_relation_reset_1(self):
+        req = self.request()
+        p1 = req.create_entity('Personne', nom=u'Vincent')
+        p2 = req.create_entity('Personne', nom=u'Florent')
+        w = req.create_entity('Affaire', ref=u'wc')
+        w.set_relations(todo_by=[p1,p2])
+        w.clear_all_caches()
+        self.commit()
+        self.assertEqual(len(w.todo_by), 1)
+        self.assertEqual(w.todo_by[0].eid, p2.eid)
+
+    def test_optional_relation_reset_2(self):
+        req = self.request()
+        p1 = req.create_entity('Personne', nom=u'Vincent')
+        p2 = req.create_entity('Personne', nom=u'Florent')
+        w = req.create_entity('Affaire', ref=u'wc')
+        w.set_relations(todo_by=p1)
+        self.commit()
+        w.set_relations(todo_by=p2)
+        w.clear_all_caches()
+        self.commit()
+        self.assertEqual(len(w.todo_by), 1)
+        self.assertEqual(w.todo_by[0].eid, p2.eid)
 
 
 if __name__ == '__main__':