def test_with_empty_args(self, mock_args): """ User passes no args, should fail with SystemExit """ with self.assertRaises(SystemExit): mock_args.return_value = argparse.Namespace(command=None, log_level=0) main()
def test_main_with_yaml_args(self): """Test main returns None with valid args.""" args = ["yaml", "aws", "-o", "large.yml"] parsed_args = self.parser.parse_args(args) options = vars(parsed_args) with patch("nise.yaml_gen.GENERATOR_MAP") as mock_get: mock_get.return_value = MockGen() with patch.object(builtins, "vars") as mock_options: with patch("nise.__main__.argparse.ArgumentParser.parse_args") as mock_args: mock_args.return_value = parsed_args mock_options.return_value = options self.assertIsNone(main())
def test_main_with_report_args(self): """ Test main returns None with valid args. """ args = ["report", "aws", "--start-date", str(date.today())] parsed_args = self.parser.parse_args(args) options = vars(parsed_args) with patch("nise.__main__.run"): with patch.object(builtins, "vars") as mock_options: with patch("nise.__main__.argparse.ArgumentParser.parse_args") as mock_args: mock_args.return_value = parsed_args mock_options.return_value = options self.assertIsNone(main())
def test_main_no_inputs(self): """ Test execution of main without inputs. """ with self.assertRaises(SystemExit): main()