135 e = req.execute('Any X WHERE X eid %(x)s', {'x': eid2}).get_entity(0, 0) |
135 e = req.execute('Any X WHERE X eid %(x)s', {'x': eid2}).get_entity(0, 0) |
136 e.copy_relations(user.eid) |
136 e.copy_relations(user.eid) |
137 req.cnx.commit() |
137 req.cnx.commit() |
138 e.cw_clear_relation_cache('in_state', 'subject') |
138 e.cw_clear_relation_cache('in_state', 'subject') |
139 self.assertEqual(e.cw_adapt_to('IWorkflowable').state, 'activated') |
139 self.assertEqual(e.cw_adapt_to('IWorkflowable').state, 'activated') |
|
140 |
|
141 def test_copy_exclude_computed_relations(self): |
|
142 """The `CWUser buddies CWUser` (computed) relation should not be copied. |
|
143 """ |
|
144 with self.admin_access.cnx() as cnx: |
|
145 friends = cnx.create_entity('CWGroup', name=u'friends') |
|
146 bob = self.create_user(cnx, u'bob', groups=('friends',)) |
|
147 cnx.create_entity('EmailAddress', address=u'bob@cubicweb.org', |
|
148 reverse_use_email=bob) |
|
149 alice = self.create_user(cnx, u'alices', groups=('friends',)) |
|
150 cnx.commit() |
|
151 charles = self.create_user(cnx, u'charles') |
|
152 cnx.commit() |
|
153 # Just ensure this does not crash (it would if computed relation |
|
154 # attempted to be copied). |
|
155 charles.copy_relations(bob.eid) |
140 |
156 |
141 def test_related_cache_both(self): |
157 def test_related_cache_both(self): |
142 with self.admin_access.web_request() as req: |
158 with self.admin_access.web_request() as req: |
143 user = req.execute('Any X WHERE X eid %(x)s', {'x':req.user.eid}).get_entity(0, 0) |
159 user = req.execute('Any X WHERE X eid %(x)s', {'x':req.user.eid}).get_entity(0, 0) |
144 adeleid = req.execute('INSERT EmailAddress X: X address "toto@logilab.org", U use_email X WHERE U login "admin"')[0][0] |
160 adeleid = req.execute('INSERT EmailAddress X: X address "toto@logilab.org", U use_email X WHERE U login "admin"')[0][0] |