def _webapp_health_monitor(argv): parser = argparse.ArgumentParser() parser.add_argument('module', type=str) args = parser.parse_args(argv) sys.path.append('.') importlib.import_module(args.module) result = VerificationSuit().run() print(result.report()) return int(result.has_failed())
def _webapp_health_monitor(argv): parser = argparse.ArgumentParser() parser.add_argument('module', type=str) parser.add_argument('--tag', type=str, default=[], action='append', dest='tags') args = parser.parse_args(argv) sys.path.append('.') importlib.import_module(args.module) result = VerificationSuit(args.tags).run() sys.stdout.write('{}\n'.format(result.report())) return int(result.has_failed())
def handle(self, *args, **options): submodules = self._get_verificator_modules() for submodule in submodules: try: importlib.import_module(submodule) except ImportError as e: if str(e) != "No module named '{}'".format(submodule): raise e result = VerificationSuit().run() print(result.report())
def handle(self, tags, **kwargs): submodules = self._get_verificator_modules() for submodule in submodules: try: importlib.import_module(submodule) except ImportError as e: if not self._import_error_concerns_verificator(submodule, e): raise e result = VerificationSuit(tags).run() self.stdout.write('{}\n'.format(result.report())) sys.exit(result.has_failed())
def test_failure(self, get_verificators): verification_error = VerificationFailure() verificator = mock.Mock(run=mock.Mock(side_effect=verification_error)) get_verificators.return_value = [verificator] verification_result = VerificationSuit([]).run() failure_report = list(verification_result.failures)[0] self.assertEqual(verificator, failure_report.verificator) self.assertEqual(verification_error, failure_report.failure) self.assertEqual([], list(verification_result.errors))
def test_error(self, get_verificators): error = NotImplementedError('value') verificator = mock.Mock(run=mock.Mock(side_effect=error)) get_verificators.return_value = [verificator] verification_result = VerificationSuit([]).run() error_report = list(verification_result.errors)[0] self.assertEqual(verificator, error_report.verificator) self.assertEqual(NotImplementedError, error_report.type) self.assertEqual(error, error_report.value) self.assertEqual([], list(verification_result.failures))
def test_success(self, get_verificators): verificator = mock.Mock() get_verificators.return_value = [verificator] verification_result = VerificationSuit([]).run() self.assertEqual([], list(verification_result.errors)) self.assertEqual([], list(verification_result.failures))