def test_generate(self, ensure_directory): # pylint: disable=protected-access, unused-argument main.GENERATORS = {"exists": mock.MagicMock()} sys.argv = ["_", "--generate", "exists"] parser = main._argument_parser() main._generate(parser.parse_args()) self.assertTrue(main.GENERATORS["exists"].called_with("/etc/starttls-policy"))
def test_generate_unknown(self): # pylint: disable=protected-access sys.argv = ["_", "--generate", "lmao"] parser = main._argument_parser() parser.error = mock.MagicMock(side_effect=Exception) self.assertRaises(Exception, main._perform, parser.parse_args(), parser)
def test_policy_dir(self): # pylint: disable=protected-access sys.argv = ["_", "--generate", "postfix", "--policy-dir", "lmao"] parser = main._argument_parser() arguments = parser.parse_args() self.assertEqual(arguments.policy_dir, "lmao")
def test_default_dir(self): # pylint: disable=protected-access sys.argv = ["_", "--generate", "postfix"] parser = main._argument_parser() arguments = parser.parse_args() self.assertEqual(arguments.policy_dir, "/etc/starttls-policy/")
def test_generate_arg(self): # pylint: disable=protected-access sys.argv = ["_", "--generate", "postfix"] parser = main._argument_parser() arguments = parser.parse_args() self.assertEqual(arguments.generate, "postfix")
def test_no_args_require_generate(self): # pylint: disable=protected-access sys.argv = ["_"] parser = main._argument_parser() parser.error = mock.MagicMock(side_effect=Exception) self.assertRaises(Exception, parser.parse_args)