f078d0e03b
Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Tests for push/sync error message localization."""
|
|
|
|
from server.utils.sync_error_message import translate_sync_error_message
|
|
|
|
|
|
class TestTranslateSyncErrorMessage:
|
|
def test_none_and_empty(self):
|
|
assert translate_sync_error_message(None) is None
|
|
assert translate_sync_error_message("") == ""
|
|
assert translate_sync_error_message(" ") == " "
|
|
|
|
def test_already_chinese_unchanged(self):
|
|
msg = "推送已取消"
|
|
assert translate_sync_error_message(msg) == msg
|
|
|
|
def test_permission_denied(self):
|
|
assert "权限被拒绝" in translate_sync_error_message("Permission denied")
|
|
|
|
def test_no_such_file(self):
|
|
assert "文件或目录不存在" in translate_sync_error_message(
|
|
"rsync: No such file or directory (2)"
|
|
)
|
|
|
|
def test_connection_refused(self):
|
|
assert "连接被拒绝" in translate_sync_error_message(
|
|
"ssh: connect to host 1.2.3.4 port 22: Connection refused"
|
|
)
|
|
|
|
def test_rsync_connection_closed(self):
|
|
assert "连接意外关闭" in translate_sync_error_message(
|
|
"rsync: connection unexpectedly closed (0 bytes received so far) [sender]"
|
|
)
|
|
|
|
def test_exit_code(self):
|
|
out = translate_sync_error_message("Command failed (exit 23)")
|
|
assert "退出码" in out
|
|
|
|
def test_server_not_found(self):
|
|
assert translate_sync_error_message("Server not found") == "服务器不存在"
|