def test_run_cluster_method(self): output = self.capture_logging('custodian.rds-cluster') def foobar(DBClusterIdentifier): raise ValueError("eek") # unspecified self.assertRaises(ValueError, _run_cluster_method, foobar, {'DBClusterIdentifier': 'mytest'}) # ignored try: _run_cluster_method(foobar, {'DBClusterIdentifier': 'mytest'}, ValueError) except ValueError: self.fail("Shouldn't raise") finally: self.assertEqual(output.getvalue(), "") # warn try: _run_cluster_method(foobar, {'DBClusterIdentifier': 'mytest'}, warn=(ValueError, KeyError)) except ValueError: self.fail("Shouldn't raise") finally: self.assertTrue("eek" in output.getvalue())
def test_run_cluster_method(self): output = self.capture_logging('custodian.rds-cluster') def foobar(DBClusterIdentifier): raise ValueError("eek") # unspecified self.assertRaises( ValueError, _run_cluster_method, foobar, {'DBClusterIdentifier': 'mytest'}) # ignored try: _run_cluster_method(foobar, {'DBClusterIdentifier': 'mytest'}, ValueError) except ValueError: self.fail("Shouldn't raise") finally: self.assertEqual(output.getvalue(), "") # warn try: _run_cluster_method( foobar, {'DBClusterIdentifier': 'mytest'}, warn=(ValueError, KeyError)) except ValueError: self.fail("Shouldn't raise") finally: self.assertTrue("eek" in output.getvalue())