Commit 85654d87 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[test] create_data_object now support being given an archive unit

Well, technically an archive unit sequence.
parent 73eeef6adc7e
......@@ -73,10 +73,7 @@ class ContainerTC(CubicWebTC):
"""Functional test for SEDA component clone."""
with self.admin_access.repo_cnx() as cnx:
unit, unit_alt, unit_alt_seq = create_archive_unit(None, cnx=cnx)
bdo = create_data_object(None, cnx=cnx)
cnx.create_entity('SEDADataObjectReference', user_cardinality=u'0..n',
seda_data_object_reference=unit_alt_seq,
seda_data_object_reference_id=bdo)
bdo = create_data_object(unit_alt_seq)
cnx.commit()
unit.cw_clear_all_caches()
......
......@@ -411,10 +411,7 @@ class CloneImportTC(CubicWebTC):
unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(None, cnx=cnx,
user_cardinality=u'1',
user_annotation=u'plop')
bdo = testutils.create_data_object(None, cnx=cnx, filename=u'file.txt')
cnx.create_entity('SEDADataObjectReference', user_cardinality=u'0..n',
seda_data_object_reference=unit_alt_seq,
seda_data_object_reference_id=bdo)
bdo = testutils.create_data_object(unit_alt_seq, filename=u'file.txt')
self.transfer_eid = transfer.eid
self.unit_eid = unit.eid
self.bdo_eid = bdo.eid
......
......@@ -39,14 +39,20 @@ def create_archive_unit(parent, **kwargs):
return au, alt, alt_seq
def create_data_object(transfer, **kwargs):
cnx = kwargs.pop('cnx', getattr(transfer, '_cw', None))
create = cnx.create_entity
def create_data_object(parent, **kwargs):
cnx = getattr(parent, '_cw', None)
kwargs.setdefault('id', u'bdo1')
bdo = create('SEDABinaryDataObject', seda_binary_data_object=transfer, **kwargs)
choice = create('SEDAAltBinaryDataObjectAttachment',
reverse_seda_alt_binary_data_object_attachment=bdo)
create('SEDAAttachment', seda_attachment=choice) # Choice cannot be empty
if parent.cw_etype == 'SEDAArchiveTransfer':
kwargs['seda_binary_data_object'] = parent
bdo = cnx.create_entity('SEDABinaryDataObject', **kwargs)
choice = cnx.create_entity('SEDAAltBinaryDataObjectAttachment',
reverse_seda_alt_binary_data_object_attachment=bdo)
cnx.create_entity('SEDAAttachment', seda_attachment=choice) # Choice cannot be empty
if parent.cw_etype != 'SEDAArchiveTransfer':
cnx.create_entity('SEDADataObjectReference', user_cardinality=u'0..n',
seda_data_object_reference=parent,
seda_data_object_reference_id=bdo)
return bdo
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment