示例#1
0
 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"))
示例#2
0
 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)
示例#3
0
 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")
示例#4
0
 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/")
示例#5
0
 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")
示例#6
0
 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)