[diagnostic] Add a comment to explain _AMBIGUOUS_RQL
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 06 Dec 2017 09:28:52 +0100
changeset 2886 09d4339eaab2
parent 2885 97d51edffffe
child 2887 1a8d43a9547b
[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.
cubicweb_seda/entities/diag.py
test/test_diag.py
--- a/cubicweb_seda/entities/diag.py	Wed Dec 06 09:27:49 2017 +0100
+++ b/cubicweb_seda/entities/diag.py	Wed Dec 06 09:28:52 2017 +0100
@@ -285,7 +285,7 @@
      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',
--- a/test/test_diag.py	Wed Dec 06 09:27:49 2017 +0100
+++ b/test/test_diag.py	Wed Dec 06 09:28:52 2017 +0100
@@ -173,6 +173,18 @@
             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')