Пример #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())