def testRegistryChecks(self): registry = QgsValidityCheckRegistry() c1 = TestCheck('c1', 'my check', 1, []) registry.addCheck(c1) c2 = TestCheck('c2', 'my check2', 2, []) registry.addCheck(c2) c3 = TestCheck('c3', 'my check3', 1, []) registry.addCheck(c3) self.assertFalse(registry.checks(0)) self.assertEqual(registry.checks(1), [c1, c3]) self.assertEqual(registry.checks(2), [c2])
def testRegistryChecks(self): registry = QgsValidityCheckRegistry() c1 = TestCheck('c1', 'my check', 1, []) registry.addCheck(c1) c2 = TestCheck('c2', 'my check2', 2, []) registry.addCheck(c2) c3 = TestCheck('c3', 'my check3', 1, []) registry.addCheck(c3) self.assertFalse(registry.checks(0)) self.assertEqual(registry.checks(1), [c1, c3]) self.assertEqual(registry.checks(2), [c2])
def testRunChecks(self): registry = QgsValidityCheckRegistry() res1 = QgsValidityCheckResult() res1.type = QgsValidityCheckResult.Warning res1.title = 'test' res1.detailedDescription = 'blah blah' c1 = TestCheck('c1', 'my check', 1, [res1]) registry.addCheck(c1) res2 = QgsValidityCheckResult() res2.type = QgsValidityCheckResult.Critical res2.title = 'test2' res2.detailedDescription = 'blah blah2' c2 = TestCheck('c2', 'my check2', 2, [res2]) registry.addCheck(c2) res3 = QgsValidityCheckResult() res3.type = QgsValidityCheckResult.Warning res3.title = 'test3' res3.detailedDescription = 'blah blah3' res4 = QgsValidityCheckResult() res4.type = QgsValidityCheckResult.Warning res4.title = 'test4' res4.detailedDescription = 'blah blah4' c3 = TestCheck('c3', 'my check3', 1, [res3, res4]) registry.addCheck(c3) context = TestContext() feedback = QgsFeedback() self.assertFalse(registry.runChecks(0, context, feedback)) self.assertEqual([r.type for r in registry.runChecks(1, context, feedback)], [QgsValidityCheckResult.Warning, QgsValidityCheckResult.Warning, QgsValidityCheckResult.Warning]) self.assertEqual([r.title for r in registry.runChecks(1, context, feedback)], ['test', 'test3', 'test4']) self.assertEqual([r.detailedDescription for r in registry.runChecks(1, context, feedback)], ['blah blah', 'blah blah3', 'blah blah4']) self.assertEqual([r.type for r in registry.runChecks(2, context, feedback)], [QgsValidityCheckResult.Critical]) self.assertEqual([r.title for r in registry.runChecks(2, context, feedback)], ['test2']) self.assertEqual([r.detailedDescription for r in registry.runChecks(2, context, feedback)], ['blah blah2'])
def testRegistry(self): registry = QgsValidityCheckRegistry() self.assertFalse(registry.checks()) # add a new check c1 = TestCheck('c1', 'my check', 1, []) registry.addCheck(c1) self.assertEqual(registry.checks(), [c1]) c2 = TestCheck('c2', 'my check2', 1, []) registry.addCheck(c2) self.assertEqual(registry.checks(), [c1, c2]) registry.removeCheck(None) c3 = TestCheck('c3', 'my check3', 1, []) # not in registry yet registry.removeCheck(c3) registry.removeCheck(c1) self.assertEqual(registry.checks(), [c2]) registry.removeCheck(c2) self.assertFalse(registry.checks())
def testRegistry(self): registry = QgsValidityCheckRegistry() self.assertFalse(registry.checks()) # add a new check c1 = TestCheck('c1', 'my check', 1, []) registry.addCheck(c1) self.assertEqual(registry.checks(), [c1]) c2 = TestCheck('c2', 'my check2', 1, []) registry.addCheck(c2) self.assertEqual(registry.checks(), [c1, c2]) registry.removeCheck(None) c3 = TestCheck('c3', 'my check3', 1, []) # not in registry yet registry.removeCheck(c3) registry.removeCheck(c1) self.assertEqual(registry.checks(), [c2]) registry.removeCheck(c2) self.assertFalse(registry.checks())
def testRunChecks(self): registry = QgsValidityCheckRegistry() res1 = QgsValidityCheckResult() res1.type = QgsValidityCheckResult.Warning res1.title = 'test' res1.detailedDescription = 'blah blah' c1 = TestCheck('c1', 'my check', 1, [res1]) registry.addCheck(c1) res2 = QgsValidityCheckResult() res2.type = QgsValidityCheckResult.Critical res2.title = 'test2' res2.detailedDescription = 'blah blah2' c2 = TestCheck('c2', 'my check2', 2, [res2]) registry.addCheck(c2) res3 = QgsValidityCheckResult() res3.type = QgsValidityCheckResult.Warning res3.title = 'test3' res3.detailedDescription = 'blah blah3' res4 = QgsValidityCheckResult() res4.type = QgsValidityCheckResult.Warning res4.title = 'test4' res4.detailedDescription = 'blah blah4' c3 = TestCheck('c3', 'my check3', 1, [res3, res4]) registry.addCheck(c3) context = TestContext() feedback = QgsFeedback() self.assertFalse(registry.runChecks(0, context, feedback)) self.assertEqual([r.type for r in registry.runChecks(1, context, feedback)], [QgsValidityCheckResult.Warning, QgsValidityCheckResult.Warning, QgsValidityCheckResult.Warning]) self.assertEqual([r.title for r in registry.runChecks(1, context, feedback)], ['test', 'test3', 'test4']) self.assertEqual([r.detailedDescription for r in registry.runChecks(1, context, feedback)], ['blah blah', 'blah blah3', 'blah blah4']) self.assertEqual([r.type for r in registry.runChecks(2, context, feedback)], [QgsValidityCheckResult.Critical]) self.assertEqual([r.title for r in registry.runChecks(2, context, feedback)], ['test2']) self.assertEqual([r.detailedDescription for r in registry.runChecks(2, context, feedback)], ['blah blah2'])