[test] Simplify test_hooks by using create_archive_unit function
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 25 Aug 2016 16:46:50 +0200
changeset 1552 05bfdace8af8
parent 1551 16d80699b01f
child 1553 f9f6974d3f6b
[test] Simplify test_hooks by using create_archive_unit function
test/test_hooks.py
--- a/test/test_hooks.py	Thu Aug 25 16:16:06 2016 +0200
+++ b/test/test_hooks.py	Thu Aug 25 16:46:50 2016 +0200
@@ -19,7 +19,7 @@
 from cubicweb.devtools.testlib import CubicWebTC
 
 from test_schema import create_transfer_to_bdo
-from test_profile_generation import scheme_for_rtype
+from test_profile_generation import scheme_for_rtype, create_archive_unit
 
 
 class ValidationHooksTC(CubicWebTC):
@@ -67,11 +67,7 @@
         with self.admin_access.client_cnx() as cnx:
             # Create an empty SEDAArchiveUnit
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
-            au = cnx.create_entity('SEDAArchiveUnit', id=u'au1', seda_archive_unit=transfer)
-            alt = cnx.create_entity('SEDAAltArchiveUnitArchiveUnitRefId',
-                                    reverse_seda_alt_archive_unit_archive_unit_ref_id=au)
-            cnx.create_entity('SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
-                              reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management=alt)
+            au, alt, seq = create_archive_unit(transfer)
             cnx.commit()
             au = cnx.entity_from_eid(au.eid)
             # Check that a SEDAContent and its title have been created
@@ -85,12 +81,7 @@
         with self.admin_access.client_cnx() as cnx:
             # Create an SEDAArchiveUnit with a SEDAContent
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
-            au = cnx.create_entity('SEDAArchiveUnit', id=u'au1', seda_archive_unit=transfer)
-            alt = cnx.create_entity('SEDAAltArchiveUnitArchiveUnitRefId',
-                                    reverse_seda_alt_archive_unit_archive_unit_ref_id=au)
-            seq = cnx.create_entity(
-                'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
-                reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management=alt)
+            au, alt, seq = create_archive_unit(transfer)
             content = cnx.create_entity('SEDAContent', seda_content=seq)
             cnx.create_entity('SEDATitle', seda_title=content)
             cnx.commit()
@@ -106,12 +97,7 @@
         with self.admin_access.client_cnx() as cnx:
             # Create an SEDAArchiveUnit with a SEDAContent
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
-            au = cnx.create_entity('SEDAArchiveUnit', id=u'au1', seda_archive_unit=transfer)
-            alt = cnx.create_entity('SEDAAltArchiveUnitArchiveUnitRefId',
-                                    reverse_seda_alt_archive_unit_archive_unit_ref_id=au)
-            seq = cnx.create_entity(
-                'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
-                reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management=alt)
+            au, alt, seq = create_archive_unit(transfer)
             content = cnx.create_entity('SEDAContent', seda_content=seq)
             cnx.create_entity('SEDATitle', seda_title=content)
             cnx.commit()