示例#1
0
    def test_private_key_only(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        with self.assertRaises(ParseError):
            parser.parse_args(
                '--address address --private-key path/to/key_file.pem')
示例#2
0
    def test_private_key_only(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        with self.assertRaises(ParseError):
            parser.parse_args(
                '--address address --private-key path/to/key_file.pem'
            )
示例#3
0
    def test_mutual_exclusion(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        with self.assertRaises(ParseError):
            parser.parse_args(
                '--socket socket --address address'.split()
            )
示例#4
0
    def test_address(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        options = parser.parse_args(
            '--address http://example.com:8000'.split())
        self.assertEqual(options.address.scheme, 'http')
        self.assertEqual(options.address.hostname, 'example.com')
        self.assertEqual(options.address.port, 8000)
示例#5
0
    def test_address(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        options = parser.parse_args(
            '--address http://example.com:8000'.split()
        )
        self.assertEqual(options.address.scheme, 'http')
        self.assertEqual(options.address.hostname, 'example.com')
        self.assertEqual(options.address.port, 8000)
示例#6
0
    def test_socket(self):
        parser = SilentArgumentParser()

        add_arguments(parser)

        options = parser.parse_args('--socket /path/to/socket'.split())

        self.assertEqual(options.socket, '/path/to/socket')
        self.assertIsNone(options.address)
        self.assertIsNone(options.fd)
        self.assertIsNone(options.certificate)
        self.assertIsNone(options.private_key)
示例#7
0
    def test_socket(self):
        parser = SilentArgumentParser()

        add_arguments(parser)

        options = parser.parse_args('--socket /path/to/socket'.split())

        self.assertEqual(options.socket, '/path/to/socket')
        self.assertIsNone(options.address)
        self.assertIsNone(options.fd)
        self.assertIsNone(options.certificate)
        self.assertIsNone(options.private_key)
示例#8
0
    def test_mutual_exclusion(self):
        parser = SilentArgumentParser()
        add_arguments(parser)

        with self.assertRaises(ParseError):
            parser.parse_args('--socket socket --address address'.split())