[test] Use testutils.create_data_object
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 18 Oct 2016 10:03:16 +0200
changeset 1846 c15f45eaad6a
parent 1845 5ec73e5b8383
child 1847 55b4f1a5d3ec
[test] Use testutils.create_data_object
test/test_profile_generation.py
--- a/test/test_profile_generation.py	Mon Oct 17 14:38:17 2016 +0200
+++ b/test/test_profile_generation.py	Tue Oct 18 10:03:16 2016 +0200
@@ -30,7 +30,7 @@
 from cubes.seda.xsd2yams import XSDMMapping
 from cubes.seda.entities.profile_generation import _path_target_values
 
-from testutils import create_archive_unit, scheme_for_rtype, scheme_for_type
+from testutils import create_archive_unit, create_data_object, scheme_for_rtype, scheme_for_type
 
 
 class XmlTestMixin(object):
@@ -298,12 +298,7 @@
     def test_skipped_mandatory_complex(self):
         with self.admin_access.client_cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
-            bdo = cnx.create_entity('SEDABinaryDataObject', id=u"bdo1",
-                                    filename=u'fixed.txt',
-                                    seda_binary_data_object=transfer)
-            bdo_alt = cnx.create_entity('SEDAAltBinaryDataObjectAttachment',
-                                        reverse_seda_alt_binary_data_object_attachment=bdo)
-            cnx.create_entity('SEDAAttachment', seda_attachment=bdo_alt)
+            create_data_object(transfer, id=u"bdo1", filename=u'fixed.txt')
             profile = self.profile_etree(transfer)
             fname = self.get_element(profile, 'Filename')
             self.assertElementDefinition(fname, {'name': 'Filename',
@@ -539,15 +534,11 @@
                                      reverse_seda_seq_access_rule_rule=access_rule)
             create('SEDAStartDate', user_cardinality=u'0..1', seda_start_date=access_rule_seq)
             # binary data object
-            bdo = create('SEDABinaryDataObject', id=u"bdo1", user_cardinality=u'0..n',
-                         seda_binary_data_object=transfer,
-                         seda_algorithm=some_concept)
+            bdo = create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
+                                     seda_algorithm=some_concept)
             create('SEDAFormatLitteral', seda_format_litteral=bdo)
             create('SEDAEncoding', seda_encoding_from=bdo)
-            bdo_alt = create('SEDAAltBinaryDataObjectAttachment',
-                             reverse_seda_alt_binary_data_object_attachment=bdo)
-            create('SEDAAttachment', seda_attachment=bdo_alt)
-            create('SEDAUri', seda_uri=bdo_alt)
+            create('SEDAUri', seda_uri=bdo.seda_alt_binary_data_object_attachment)
             # first level archive unit
             unit, unit_alt, unit_alt_seq = create_archive_unit(transfer, user_cardinality=u'0..n',
                                                                user_annotation=u'Composant ISAD(G)')
@@ -754,14 +745,8 @@
 
             # Add minimal document to first level archive
             ref = create('SEDADataObjectReference', seda_data_object_reference=unit_alt_seq)
-            bdo_alt = cnx.create_entity('SEDAAltBinaryDataObjectAttachment')
-            cnx.create_entity('SEDAAttachment', seda_attachment=bdo_alt)
-            bdo = create('SEDABinaryDataObject', id=u'bdo1',
-                         user_cardinality=u'0..n',
-                         # seda_description=create('SEDADescription'),
-                         seda_binary_data_object=transfer,
-                         seda_alt_binary_data_object_attachment=bdo_alt,
-                         reverse_seda_data_object_reference_id=ref)
+            bdo = create_data_object(transfer, id=u"bdo1", user_cardinality=u'0..n',
+                                     reverse_seda_data_object_reference_id=ref)
 
             create('SEDAFormatId',
                    user_cardinality=u'1',