Fix bug
This commit is contained in:
@@ -71,6 +71,25 @@ class TokenManagementTest(unittest.TestCase):
|
||||
self.assertIn("CPU: 12.5%", mobile)
|
||||
self.assertIn("SSH: 1 on / 2 total", mobile)
|
||||
|
||||
def test_menu_clears_on_open_and_redraw_after_output_pause(self):
|
||||
output = io.StringIO()
|
||||
with redirect_stdout(output), patch.object(output, "isatty", return_value=True), \
|
||||
patch.object(cli.sys, "stdin", SimpleNamespace(isatty=lambda: True)), \
|
||||
patch("builtins.input", side_effect=["1", "", "0"]) as ask:
|
||||
cli.menu("TEST", {"1": ("Show result", lambda: print("RESULT"))})
|
||||
self.assertEqual(output.getvalue().count("\033[2J\033[H"), 2)
|
||||
self.assertIn("RESULT", output.getvalue())
|
||||
self.assertIn("Press Enter to return", ask.call_args_list[1].args[0])
|
||||
|
||||
def test_returning_from_submenu_redraws_without_extra_pause(self):
|
||||
output = io.StringIO()
|
||||
with redirect_stdout(output), patch.object(output, "isatty", return_value=True), \
|
||||
patch.object(cli.sys, "stdin", SimpleNamespace(isatty=lambda: True)), \
|
||||
patch("builtins.input", side_effect=["1", "0", "0"]) as ask:
|
||||
cli.menu("PARENT", {"1": ("Submenu", lambda: cli.menu("CHILD", {}))})
|
||||
self.assertEqual(ask.call_count, 3)
|
||||
self.assertEqual(output.getvalue().count("\033[2J\033[H"), 3)
|
||||
|
||||
def test_user_list_fits_phone_terminal(self):
|
||||
users = [{"username": "account-with-a-long-name", "active_conns": 2,
|
||||
"max_connections": 5, "total_bytes": 1234567,
|
||||
@@ -116,6 +135,20 @@ class TokenManagementTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(cli.CLIError, "native"):
|
||||
cli.xray_shared_port()
|
||||
|
||||
def test_xray_client_id_is_displayed_and_editable(self):
|
||||
inbounds = [{"tag": "vless", "protocol": "vless", "clients": [
|
||||
{"id": "client-uuid", "name": "alice", "max_conns": 2}
|
||||
]}]
|
||||
with patch.object(cli, "request", return_value=inbounds) as request, \
|
||||
patch.object(cli, "ask", side_effect=["client-uuid", "2"]), \
|
||||
patch.object(cli, "number", return_value=3), \
|
||||
redirect_stdout(io.StringIO()) as output:
|
||||
cli.xray_inbounds()
|
||||
cli.xray_edit()
|
||||
self.assertIn("client-uuid", output.getvalue())
|
||||
self.assertEqual(request.call_args.args[:2], ("POST", "/api/xray/clients/update"))
|
||||
self.assertEqual(request.call_args.args[2]["uuid"], "client-uuid")
|
||||
|
||||
def test_git_update_uses_installed_updater_without_prompt(self):
|
||||
updater = Path(self.temp.name) / "update.sh"
|
||||
updater.write_text("#!/bin/bash\n")
|
||||
|
||||
Reference in New Issue
Block a user