[PATCH 09 of 13 saem_ref] [test] Fix automatic test

Sylvain Thenault sylvain.thenault at logilab.fr
Fri Mar 31 17:57:21 CEST 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1490967328 -7200
#      Fri Mar 31 15:35:28 2017 +0200
# Node ID 328c24fa67cdcc9e0fb7816804a53b80990c1720
# Parent  b27f3315d0d164ed9ebb7bb3f32d6b07754e5b42
[test] Fix automatic test

by using function from testutils to create archive unit and data object instead
of reimplementing most of them in there.

diff --git a/test/test_saem_ref.py b/test/test_saem_ref.py
--- a/test/test_saem_ref.py
+++ b/test/test_saem_ref.py
@@ -105,13 +105,11 @@ class AutomaticWebTest(testlib.Automatic
 
     @property
     def no_auto_populate(self):
         seda_types_to_skip = [eschema.type for eschema in self.schema.entities()
                               if eschema.type.startswith('SEDA')
-                              and eschema not in ('SEDAArchiveTransfer',
-                                                  'SEDAArchiveUnit',
-                                                  'SEDABinaryDataObject')]
+                              and eschema != 'SEDAArchiveTransfer']
         eac_types_to_skip = ['EACResourceRelation',
                              'HierarchicalRelation',
                              'ChronologicalRelation',
                              'AssociationRelation']
         cw_types_to_skip = [etype for etype in SCHEMA_TYPES
@@ -129,25 +127,13 @@ class AutomaticWebTest(testlib.Automatic
                              or 'ExternalUril' in rschema.subjects()]
 
         return set(seda_types_to_skip + ext_types_to_skip + ['use_email'])
 
     def post_populate(self, cnx):
-        unit = cnx.find('SEDAArchiveUnit').one()
-        alt = cnx.create_entity('SEDAAltArchiveUnitArchiveUnitRefId',
-                                reverse_seda_alt_archive_unit_archive_unit_ref_id=unit)
-        alt_seq = cnx.create_entity(
-            'SEDASeqAltArchiveUnitArchiveUnitRefIdManagement',
-            reverse_seda_seq_alt_archive_unit_archive_unit_ref_id_management=alt)
-        cnx.create_entity('SEDATitle', seda_title=alt_seq, title=u'h&')
-
-        bdo = cnx.find('SEDABinaryDataObject').one()
-        choice = cnx.create_entity('SEDAAltBinaryDataObjectAttachment',
-                                   reverse_seda_alt_binary_data_object_attachment=bdo)
-        cnx.create_entity('SEDAAttachment', seda_attachment=choice)
-        cnx.create_entity('SEDADataObjectReference', user_cardinality=u'0..n',
-                          seda_data_object_reference=alt_seq,
-                          seda_data_object_reference_id=bdo)
+        unit, alt, alt_seq = testutils.create_archive_unit(
+            cnx.find('SEDAArchiveTransfer').one())
+        testutils.create_data_object(alt_seq)
 
         cnx.execute('SET L kind "preferred" WHERE NOT EXISTS (L label_of X, L kind "preferred")')
 
     def to_test_etypes(self):
         '''only test views for entities of the returned types'''


More information about the saem-devel mailing list