add python class RpcUnixSocket (does not completely work yet)

This commit is contained in:
Simon Laux
2026-01-12 16:06:19 +01:00
parent 3352b8d5f6
commit 998ab6e298
4 changed files with 316 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
from os import environ
import platform # noqa
import signal
import subprocess
from sys import stderr
from time import sleep
import pytest
from deltachat_rpc_client import DeltaChat, RpcUnixSocket
@pytest.mark.skipif("platform.system() == 'Windows'")
def test_rpc_unix(tmp_path):
socket_file = "/tmp/chatmail.sock" # path needs to be relative or short
path = environ.get("PATH")
assert path is not None
popen = subprocess.Popen(
f"deltachat-rpc-server --unix {socket_file}",
shell=True,
env=dict(
DC_ACCOUNTS_PATH=f"{tmp_path}/accounts/test",
rust_log="info",
PATH=path
)
)
sleep(1) # wait until socket exists # TODO this should not be needed
rpc = RpcUnixSocket(socket_path=socket_file)
with rpc:
dc = DeltaChat(rpc)
assert dc.rpc.get_system_info()["deltachat_core_version"] is not None
popen.send_signal(signal.SIGINT)
popen.wait()