def test_main_loglevel(self): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'logging') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'DeBuG' _args.dev = False _args.smoke = False self.parse_args.return_value = _args self.logging.DEBUG = 10 lc_func_test_runner.main() self.logging.basicConfig.assert_called_with(level=10)
def test_main_loglevel_invalid(self): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'logging') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'invalid' self.parse_args.return_value = _args with self.assertRaises(ValueError) as context: lc_func_test_runner.main() self.assertEqual( 'Invalid log level: "invalid"', str(context.exception)) self.assertFalse(self.logging.basicConfig.called)
def test_main_smoke_dev_ambiguous(self): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'cli_utils') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'DEBUG' _args.dev = True _args.smoke = True self.parse_args.return_value = _args with self.assertRaises(ValueError) as context: lc_func_test_runner.main() self.assertEqual( 'Ambiguous arguments: --smoke and --dev cannot be used together', str(context.exception))
def test_main_bundle_smoke_ambiguous(self): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'logging') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'DEBUG' _args.dev = False _args.smoke = True _args.bundle = 'foo.yaml' self.parse_args.return_value = _args self.logging.DEBUG = 10 with self.assertRaises(ValueError) as context: lc_func_test_runner.main() self.assertEqual( ('Ambiguous arguments: --bundle and --smoke ' 'cannot be used together'), str(context.exception))
def __keep_model_ambiguous( self, last_model=False, all_models=False, faulty_model=False ): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'cli_utils') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'DEBUG' _args.keep_last_model = last_model _args.keep_all_models = all_models _args.keep_faulty_model = faulty_model self.parse_args.return_value = _args with self.assertRaises(ValueError) as context: lc_func_test_runner.main() self.assertEqual( ('Ambiguous arguments: --keep-last-model ' '(previously, --keep-model), --keep-all-models ' 'and --keep-faulty-model cannot be used together'), str(context.exception))
def test_main_bundle_smoke_ambiguous(self): self.patch_object(lc_func_test_runner, 'parse_args') self.patch_object(lc_func_test_runner, 'cli_utils') self.patch_object(lc_func_test_runner, 'func_test_runner') self.patch_object(lc_func_test_runner, 'asyncio') _args = mock.Mock() _args.loglevel = 'DEBUG' _args.keep_last_model = False _args.keep_all_models = False _args.keep_faulty_model = False _args.dev = False _args.smoke = True _args.bundles = ['foo.yaml'] self.parse_args.return_value = _args with self.assertRaises(ValueError) as context: lc_func_test_runner.main() self.assertEqual( ('Ambiguous arguments: --bundle and --smoke ' 'cannot be used together'), str(context.exception))