273 [key.split(':')[0] |
273 [key.split(':')[0] |
274 for key in kwargs.keys() |
274 for key in kwargs.keys() |
275 if not key.startswith('_')]) |
275 if not key.startswith('_')]) |
276 self.expect_redirect_handle_request(req) |
276 self.expect_redirect_handle_request(req) |
277 |
277 |
|
278 def _edit_in_version(self, ticket_eid, version_eid, **kwargs): |
|
279 version_eid = version_eid or '__cubicweb_internal_field__' |
|
280 with self.admin_access.web_request() as req: |
|
281 req.form = { |
|
282 'eid': unicode(ticket_eid), |
|
283 '__maineid': unicode(ticket_eid), |
|
284 '__type:%s' % ticket_eid: 'Ticket', |
|
285 'in_version-subject:%s' % ticket_eid: version_eid, |
|
286 } |
|
287 req.form.update(kwargs) |
|
288 req.form['_cw_entity_fields:%s' % ticket_eid] = ','.join( |
|
289 ['in_version-subject'] + |
|
290 [key.split(':')[0] |
|
291 for key in kwargs.keys() |
|
292 if not key.startswith('_')]) |
|
293 self.expect_redirect_handle_request(req) |
|
294 |
278 def test_create_and_link_directories(self): |
295 def test_create_and_link_directories(self): |
279 with self.admin_access.web_request() as req: |
296 with self.admin_access.web_request() as req: |
280 req.form = { |
297 req.form = { |
281 'eid': (u'A', u'B'), |
298 'eid': (u'A', u'B'), |
282 '__maineid': u'A', |
299 '__maineid': u'A', |
371 self.assertTrue(cnx.find('Directory', eid=top1.eid)) |
388 self.assertTrue(cnx.find('Directory', eid=top1.eid)) |
372 self.assertTrue(cnx.find('Directory', eid=top2.eid)) |
389 self.assertTrue(cnx.find('Directory', eid=top2.eid)) |
373 self.assertTrue(cnx.find('Directory', eid=subd.eid)) |
390 self.assertTrue(cnx.find('Directory', eid=subd.eid)) |
374 self.assertEqual( |
391 self.assertEqual( |
375 cnx.find('Directory', eid=subd.eid).one().parent[0], top2) |
392 cnx.find('Directory', eid=subd.eid).one().parent[0], top2) |
|
393 |
|
394 def test_reparent_subentity_inlined(self): |
|
395 """Editcontroller: re-parenting a subentity does not remove it |
|
396 (inlined case)""" |
|
397 with self.admin_access.repo_cnx() as cnx: |
|
398 version1 = cnx.create_entity('Version', name=u'version1') |
|
399 version2 = cnx.create_entity('Version', name=u'version2') |
|
400 ticket = cnx.create_entity('Ticket', title=u'ticket', |
|
401 in_version=version1) |
|
402 cnx.commit() |
|
403 |
|
404 self._edit_in_version(ticket.eid, version_eid=version2.eid) |
|
405 |
|
406 with self.admin_access.repo_cnx() as cnx: |
|
407 self.assertTrue(cnx.find('Version', eid=version1.eid)) |
|
408 self.assertTrue(cnx.find('Version', eid=version2.eid)) |
|
409 self.assertTrue(cnx.find('Ticket', eid=ticket.eid)) |
|
410 self.assertEqual( |
|
411 cnx.find('Ticket', eid=ticket.eid).one().in_version[0], version2) |
376 |
412 |
377 def test_subject_mixed_composite_subentity_removal_1(self): |
413 def test_subject_mixed_composite_subentity_removal_1(self): |
378 """Editcontroller: detaching several subentities respects each rdef's |
414 """Editcontroller: detaching several subentities respects each rdef's |
379 compositeness - Remove non composite |
415 compositeness - Remove non composite |
380 """ |
416 """ |