[test] Rename assertDiagnostic to assertFailingRules
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 02 Nov 2017 20:42:48 +0100
changeset 2826 54a83326c9a5
parent 2825 97404ac46824
child 2827 0f1331287a4c
[test] Rename assertDiagnostic to assertFailingRules since this is the underlying method of the diagnosis tool, and we'll want more testing utilities in later csets. Related to #39302963
test/test_diag.py
--- a/test/test_diag.py	Thu Nov 02 20:41:10 2017 +0100
+++ b/test/test_diag.py	Thu Nov 02 20:42:48 2017 +0100
@@ -29,26 +29,26 @@
             transfer = create('SEDAArchiveTransfer', title=u'diagnosis testing')
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'SEDA 0.2', 'simplified'])
+            self.assertFailingRules(doctor, ['SEDA 2.0', 'SEDA 1.0', 'SEDA 0.2', 'simplified'])
 
             unit, unit_alt, unit_alt_seq = testutils.create_archive_unit(transfer)
             transfer.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 0.2', 'simplified'],
-                                  'seda1_need_access_rule')
+            self.assertFailingRules(doctor, ['SEDA 2.0', 'SEDA 0.2', 'simplified'],
+                                    'seda1_need_access_rule')
 
             access_rule = create('SEDAAccessRule', seda_access_rule=unit_alt_seq)
             unit_alt_seq.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'], 'rule_without_rule')
+            self.assertFailingRules(doctor, ['SEDA 2.0'], 'rule_without_rule')
 
             access_rule_seq = create('SEDASeqAccessRuleRule',
                                      user_cardinality=u'1..n',
                                      reverse_seda_seq_access_rule_rule=access_rule)
             access_rule.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'],
-                                  'rule_unsupported_card', 'rule_need_start_date')
+            self.assertFailingRules(doctor, ['SEDA 2.0'],
+                                    'rule_unsupported_card', 'rule_need_start_date')
 
             access_rule_seq.cw_set(user_cardinality=u'1')
             start_date = create('SEDAStartDate',
@@ -56,8 +56,8 @@
                                 seda_start_date=access_rule_seq)
             access_rule_seq.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'],
-                                  'rule_start_unsupported_card')
+            self.assertFailingRules(doctor, ['SEDA 2.0'],
+                                    'rule_start_unsupported_card')
 
             start_date.cw_set(user_cardinality=u'1')
             start_date.cw_clear_all_caches()
@@ -66,8 +66,8 @@
                                       reverse_seda_seq_access_rule_rule=access_rule)
             access_rule.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'],
-                                  'rule_with_too_much_rules')
+            self.assertFailingRules(doctor, ['SEDA 2.0'],
+                                    'rule_with_too_much_rules')
 
             access_rule_seq2.cw_delete()
             inherit_ctl = create('SEDAAltAccessRulePreventInheritance',
@@ -75,8 +75,8 @@
             create('SEDARefNonRuleId', seda_ref_non_rule_id_from=inherit_ctl)
             access_rule.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'],
-                                  'rule_ref_non_rule_id')
+            self.assertFailingRules(doctor, ['SEDA 2.0'],
+                                    'rule_ref_non_rule_id')
 
     def test_custodial_history(self):
         with self.admin_access.cnx() as cnx:
@@ -97,22 +97,22 @@
 
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'SEDA 0.2', 'simplified'])
+            self.assertFailingRules(doctor, ['SEDA 2.0', 'SEDA 1.0', 'SEDA 0.2', 'simplified'])
 
             history_item2 = create('SEDACustodialHistoryItem',
                                    seda_custodial_history_item=unit_alt_seq)
             unit_alt_seq.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
-                                  'seda02_custodial_history_items')
+            self.assertFailingRules(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
+                                    'seda02_custodial_history_items')
 
             history_item2.cw_delete()
             create('SEDAwhen', seda_when=history_item)
             unit_alt_seq.cw_clear_all_caches()
             history_item.cw_clear_all_caches()
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
-                                  'seda02_custodial_history_when')
+            self.assertFailingRules(doctor, ['SEDA 2.0', 'SEDA 1.0', 'simplified'],
+                                    'seda02_custodial_history_when')
 
     def test_archive_unit_reference_in_transfer(self):
         with self.admin_access.cnx() as cnx:
@@ -121,7 +121,7 @@
 
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'], 'use_archive_unit_ref')
+            self.assertFailingRules(doctor, ['SEDA 2.0'], 'use_archive_unit_ref')
 
     def test_archive_unit_reference_in_archive_unit(self):
         with self.admin_access.cnx() as cnx:
@@ -131,10 +131,10 @@
 
             doctor = transfer.cw_adapt_to('ISEDACompatAnalyzer')
             cnx.commit()
-            self.assertDiagnostic(doctor, ['SEDA 2.0'],
-                                  'use_archive_unit_ref', 'seda1_need_access_rule')
+            self.assertFailingRules(doctor, ['SEDA 2.0'],
+                                    'use_archive_unit_ref', 'seda1_need_access_rule')
 
-    def assertDiagnostic(self, doctor, expected_formats, *expected_rule_ids):
+    def assertFailingRules(self, doctor, expected_formats, *expected_rule_ids):
         doctor.entity.cw_clear_all_caches()
         rule_ids = set(rule_id for rule_id, entity in doctor.failing_rules())
         self.assertEqual(rule_ids, set(expected_rule_ids))