[PATCH 2 of 2 seda] [diagnostic] Add a comment to explain _AMBIGUOUS_RQL

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Dec 6 09:57:56 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1512548932 -3600
#      Wed Dec 06 09:28:52 2017 +0100
# Node ID 09d4339eaab2c99ec60b79e9f50bd61fb47b97e7
# Parent  97d51edffffe26ff0468c4d062b9de705d8bcaf3
[diagnostic] Add a comment to explain _AMBIGUOUS_RQL

and add a test for ambiguous units under a sub-unit, to have a case for archive
units handled by each query.

diff --git a/cubicweb_seda/entities/diag.py b/cubicweb_seda/entities/diag.py
--- a/cubicweb_seda/entities/diag.py
+++ b/cubicweb_seda/entities/diag.py
@@ -283,11 +283,11 @@ def _parent(entity):
     ('(Any P, "{rtype}" GROUPBY P WHERE X {rtype} P, P container C, C eid %(c)s, '
      'NOT X user_cardinality "1" HAVING COUNT(X) > 1)'.format(rtype=rtype)
      for rtype in _RTYPE_TO_TAB if rtype not in ('seda_binary_data_object',
                                                  'seda_physical_data_object',
                                                  'seda_related_transfer_reference')),
-
+    # we need another RQL for top level entities without container relation
     ('(Any P, "{rtype}" GROUPBY P WHERE X {rtype} P, P eid %(c)s, '
      'NOT X user_cardinality "1" HAVING COUNT(X) > 1)'.format(rtype=rtype)
      for rtype in ('seda_archive_unit',
                    'seda_binary_data_object', 'seda_physical_data_object',
                    'seda_related_transfer_reference')),
diff --git a/test/test_diag.py b/test/test_diag.py
--- a/test/test_diag.py
+++ b/test/test_diag.py
@@ -171,10 +171,22 @@ class CompatAnalyzerTC(CubicWebTC):
 
             unit3.cw_delete()
             cnx.commit()
             self.assertIsRNGAmbiguous(transfer, False)
 
+    def test_multiple_child_unhandled_cardinality_sub_archive_unit(self):
+        with self.admin_access.cnx() as cnx:
+            transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
+            doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
+            unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
+            testutils.create_archive_unit(unit_alt_seq, user_cardinality=u'1..n')
+            testutils.create_archive_unit(unit_alt_seq, user_cardinality=u'1..n')
+            cnx.commit()
+
+            self.assertIsRNGAmbiguous(transfer, True)
+            self.assertErrorOn(doctor, 'rng_ambiguity', [(unit, 'seda_archive_units_tab')])
+
     def test_multiple_child_unhandled_cardinality_document(self):
         with self.admin_access.cnx() as cnx:
             transfer = cnx.create_entity('SEDAArchiveTransfer', title=u'test profile')
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)


More information about the saem-devel mailing list