重写为多协议管理器: 6 协议, CLI + curses TUI, 用户级 systemd
This commit is contained in:
1 parent
c43ab4a16e
commit
237b958e41
71 files changed
+4599
-1171
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import unittest
|
||||
|
||||
from sbp import commands, protocols
|
||||
from sbp.cli import build_parser
|
||||
|
||||
|
||||
class ParserTest(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.parser = build_parser()
|
||||
|
||||
def test_every_command_has_a_module(self) -> None:
|
||||
sub = next(
|
||||
action for action in self.parser._actions if action.dest == "command"
|
||||
)
|
||||
registered = set(sub.choices)
|
||||
self.assertEqual(registered, set(commands.COMMANDS))
|
||||
|
||||
def test_protocol_choices_match_registry(self) -> None:
|
||||
args = self.parser.parse_args(["protocol", "enable", "hysteria2", "--port", "24000"])
|
||||
self.assertEqual(args.command, "protocol")
|
||||
self.assertEqual(args.action, "enable")
|
||||
self.assertEqual(args.port, 24000)
|
||||
self.assertEqual(set(protocols.keys()), set(protocols.REGISTRY))
|
||||
|
||||
def test_user_show_options(self) -> None:
|
||||
args = self.parser.parse_args(
|
||||
["user", "show", "phone", "--protocol", "trojan", "--json"]
|
||||
)
|
||||
self.assertEqual(args.name, "phone")
|
||||
self.assertEqual(args.protocol, "trojan")
|
||||
self.assertTrue(args.json)
|
||||
|
||||
def test_install_defaults(self) -> None:
|
||||
args = self.parser.parse_args(["install"])
|
||||
self.assertEqual(args.base_port, 20000)
|
||||
self.assertFalse(args.force)
|
||||
self.assertIsNone(args.protocols)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user