28 lines
955 B
Python
28 lines
955 B
Python
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import io
|
|
import unittest
|
|
|
|
from vpn_egressctl.cli import _parser
|
|
|
|
|
|
class CliTests(unittest.TestCase):
|
|
def test_uri_positional_argument_is_rejected(self) -> None:
|
|
with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit):
|
|
_parser().parse_args(["import", "hysteria2://secret@example.com"])
|
|
|
|
def test_render_command_is_not_public(self) -> None:
|
|
with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit):
|
|
_parser().parse_args(["render", "--output", "/etc/sing-box/config.json"])
|
|
|
|
def test_all_commands_parse(self) -> None:
|
|
for command in ("check", "diff", "sync", "status", "doctor", "rollback"):
|
|
with self.subTest(command=command):
|
|
args = _parser().parse_args([command])
|
|
self.assertEqual(args.command, command)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|