deltachat-rpc-client 2.29.0__py3-none-any.whl → 2.31.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- deltachat_rpc_client/const.py +1 -0
- deltachat_rpc_client/pytestplugin.py +148 -0
- deltachat_rpc_client/rpc.py +1 -1
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/METADATA +10 -1
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/RECORD +9 -9
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/WHEEL +0 -0
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/entry_points.txt +0 -0
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/licenses/LICENSE +0 -0
- {deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/top_level.txt +0 -0
deltachat_rpc_client/const.py
CHANGED
|
@@ -80,6 +80,7 @@ class EventType(str, Enum):
|
|
|
80
80
|
CONFIG_SYNCED = "ConfigSynced"
|
|
81
81
|
WEBXDC_REALTIME_DATA = "WebxdcRealtimeData"
|
|
82
82
|
WEBXDC_REALTIME_ADVERTISEMENT_RECEIVED = "WebxdcRealtimeAdvertisementReceived"
|
|
83
|
+
TRANSPORTS_MODIFIED = "TransportsModified"
|
|
83
84
|
|
|
84
85
|
|
|
85
86
|
class ChatId(IntEnum):
|
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
|
+
import pathlib
|
|
7
|
+
import platform
|
|
6
8
|
import random
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
7
11
|
from typing import AsyncGenerator, Optional
|
|
8
12
|
|
|
13
|
+
import execnet
|
|
9
14
|
import py
|
|
10
15
|
import pytest
|
|
11
16
|
|
|
@@ -20,6 +25,18 @@ Currently this is "End-to-end encryption available".
|
|
|
20
25
|
"""
|
|
21
26
|
|
|
22
27
|
|
|
28
|
+
def pytest_report_header():
|
|
29
|
+
for base in os.get_exec_path():
|
|
30
|
+
fn = pathlib.Path(base).joinpath(base, "deltachat-rpc-server")
|
|
31
|
+
if fn.exists():
|
|
32
|
+
proc = subprocess.Popen([str(fn), "--version"], stderr=subprocess.PIPE)
|
|
33
|
+
proc.wait()
|
|
34
|
+
version = proc.stderr.read().decode().strip()
|
|
35
|
+
return f"deltachat-rpc-server: {fn} [{version}]"
|
|
36
|
+
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
|
|
23
40
|
class ACFactory:
|
|
24
41
|
"""Test account factory."""
|
|
25
42
|
|
|
@@ -197,3 +214,134 @@ def log():
|
|
|
197
214
|
print(" " + msg)
|
|
198
215
|
|
|
199
216
|
return Printer()
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
#
|
|
220
|
+
# support for testing against different deltachat-rpc-server/clients
|
|
221
|
+
# installed into a temporary virtualenv and connected via 'execnet' channels
|
|
222
|
+
#
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def find_path(venv, name):
|
|
226
|
+
is_windows = platform.system() == "Windows"
|
|
227
|
+
bin = venv / ("bin" if not is_windows else "Scripts")
|
|
228
|
+
|
|
229
|
+
tryadd = [""]
|
|
230
|
+
if is_windows:
|
|
231
|
+
tryadd += os.environ["PATHEXT"].split(os.pathsep)
|
|
232
|
+
for ext in tryadd:
|
|
233
|
+
p = bin.joinpath(name + ext)
|
|
234
|
+
if p.exists():
|
|
235
|
+
return str(p)
|
|
236
|
+
|
|
237
|
+
return None
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@pytest.fixture(scope="session")
|
|
241
|
+
def get_core_python_env(tmp_path_factory):
|
|
242
|
+
"""Return a factory to create virtualenv environments with rpc server/client packages
|
|
243
|
+
installed.
|
|
244
|
+
|
|
245
|
+
The factory takes a version and returns a (python_path, rpc_server_path) tuple
|
|
246
|
+
of the respective binaries in the virtualenv.
|
|
247
|
+
"""
|
|
248
|
+
|
|
249
|
+
envs = {}
|
|
250
|
+
|
|
251
|
+
def get_versioned_venv(core_version):
|
|
252
|
+
venv = envs.get(core_version)
|
|
253
|
+
if not venv:
|
|
254
|
+
venv = tmp_path_factory.mktemp(f"temp-{core_version}")
|
|
255
|
+
subprocess.check_call([sys.executable, "-m", "venv", venv])
|
|
256
|
+
|
|
257
|
+
python = find_path(venv, "python")
|
|
258
|
+
pkgs = [f"deltachat-rpc-server=={core_version}", f"deltachat-rpc-client=={core_version}", "pytest"]
|
|
259
|
+
subprocess.check_call([python, "-m", "pip", "install"] + pkgs)
|
|
260
|
+
|
|
261
|
+
envs[core_version] = venv
|
|
262
|
+
python = find_path(venv, "python")
|
|
263
|
+
rpc_server_path = find_path(venv, "deltachat-rpc-server")
|
|
264
|
+
print(f"python={python}\nrpc_server={rpc_server_path}")
|
|
265
|
+
return python, rpc_server_path
|
|
266
|
+
|
|
267
|
+
return get_versioned_venv
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
@pytest.fixture
|
|
271
|
+
def alice_and_remote_bob(tmp_path, acfactory, get_core_python_env):
|
|
272
|
+
"""return local Alice account, a contact to bob, and a remote 'eval' function for bob.
|
|
273
|
+
|
|
274
|
+
The 'eval' function allows to remote-execute arbitrary expressions
|
|
275
|
+
that can use the `bob` online account, and the `bob_contact_alice`.
|
|
276
|
+
"""
|
|
277
|
+
|
|
278
|
+
def factory(core_version):
|
|
279
|
+
python, rpc_server_path = get_core_python_env(core_version)
|
|
280
|
+
gw = execnet.makegateway(f"popen//python={python}")
|
|
281
|
+
|
|
282
|
+
accounts_dir = str(tmp_path.joinpath("account1_venv1"))
|
|
283
|
+
channel = gw.remote_exec(remote_bob_loop)
|
|
284
|
+
cm = os.environ.get("CHATMAIL_DOMAIN")
|
|
285
|
+
|
|
286
|
+
# trigger getting an online account on bob's side
|
|
287
|
+
channel.send((accounts_dir, str(rpc_server_path), cm))
|
|
288
|
+
|
|
289
|
+
# meanwhile get a local alice account
|
|
290
|
+
alice = acfactory.get_online_account()
|
|
291
|
+
channel.send(alice.self_contact.make_vcard())
|
|
292
|
+
|
|
293
|
+
# wait for bob to have started
|
|
294
|
+
sysinfo = channel.receive()
|
|
295
|
+
assert sysinfo == f"v{core_version}"
|
|
296
|
+
bob_vcard = channel.receive()
|
|
297
|
+
[alice_contact_bob] = alice.import_vcard(bob_vcard)
|
|
298
|
+
|
|
299
|
+
def eval(eval_str):
|
|
300
|
+
channel.send(eval_str)
|
|
301
|
+
return channel.receive()
|
|
302
|
+
|
|
303
|
+
return alice, alice_contact_bob, eval
|
|
304
|
+
|
|
305
|
+
return factory
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def remote_bob_loop(channel):
|
|
309
|
+
# This function executes with versioned
|
|
310
|
+
# deltachat-rpc-client/server packages
|
|
311
|
+
# installed into the virtualenv.
|
|
312
|
+
#
|
|
313
|
+
# The "channel" argument is a send/receive pipe
|
|
314
|
+
# to the process that runs the corresponding remote_exec(remote_bob_loop)
|
|
315
|
+
|
|
316
|
+
import os
|
|
317
|
+
|
|
318
|
+
from deltachat_rpc_client import DeltaChat, Rpc
|
|
319
|
+
from deltachat_rpc_client.pytestplugin import ACFactory
|
|
320
|
+
|
|
321
|
+
accounts_dir, rpc_server_path, chatmail_domain = channel.receive()
|
|
322
|
+
os.environ["CHATMAIL_DOMAIN"] = chatmail_domain
|
|
323
|
+
|
|
324
|
+
# older core versions don't support specifying rpc_server_path
|
|
325
|
+
# so we can't just pass `rpc_server_path` argument to Rpc constructor
|
|
326
|
+
basepath = os.path.dirname(rpc_server_path)
|
|
327
|
+
os.environ["PATH"] = os.pathsep.join([basepath, os.environ["PATH"]])
|
|
328
|
+
rpc = Rpc(accounts_dir=accounts_dir)
|
|
329
|
+
|
|
330
|
+
with rpc:
|
|
331
|
+
dc = DeltaChat(rpc)
|
|
332
|
+
channel.send(dc.rpc.get_system_info()["deltachat_core_version"])
|
|
333
|
+
acfactory = ACFactory(dc)
|
|
334
|
+
bob = acfactory.get_online_account()
|
|
335
|
+
alice_vcard = channel.receive()
|
|
336
|
+
[alice_contact] = bob.import_vcard(alice_vcard)
|
|
337
|
+
ns = {"bob": bob, "bob_contact_alice": alice_contact}
|
|
338
|
+
channel.send(bob.self_contact.make_vcard())
|
|
339
|
+
|
|
340
|
+
while 1:
|
|
341
|
+
eval_str = channel.receive()
|
|
342
|
+
res = eval(eval_str, ns)
|
|
343
|
+
try:
|
|
344
|
+
channel.send(res)
|
|
345
|
+
except Exception:
|
|
346
|
+
# some unserializable result
|
|
347
|
+
channel.send(None)
|
deltachat_rpc_client/rpc.py
CHANGED
|
@@ -57,7 +57,7 @@ class Rpc:
|
|
|
57
57
|
def __init__(self, accounts_dir: Optional[str] = None, rpc_server_path="deltachat-rpc-server", **kwargs):
|
|
58
58
|
"""Initialize RPC client.
|
|
59
59
|
|
|
60
|
-
The
|
|
60
|
+
The 'kwargs' arguments will be passed to subprocess.Popen().
|
|
61
61
|
"""
|
|
62
62
|
if accounts_dir:
|
|
63
63
|
kwargs["env"] = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deltachat-rpc-client
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.31.0
|
|
4
4
|
Summary: Python client for Delta Chat core JSON-RPC interface
|
|
5
5
|
License-Expression: MPL-2.0
|
|
6
6
|
Classifier: Development Status :: 5 - Production/Stable
|
|
@@ -52,6 +52,15 @@ $ pip install .
|
|
|
52
52
|
|
|
53
53
|
Additional arguments to `tox` are passed to pytest, e.g. `tox -- -s` does not capture test output.
|
|
54
54
|
|
|
55
|
+
|
|
56
|
+
## Activating current checkout of deltachat-rpc-client and -server for development
|
|
57
|
+
|
|
58
|
+
Go to root repository directory and run:
|
|
59
|
+
```
|
|
60
|
+
$ scripts/make-rpc-testenv.sh
|
|
61
|
+
$ source venv/bin/activate
|
|
62
|
+
```
|
|
63
|
+
|
|
55
64
|
## Using in REPL
|
|
56
65
|
|
|
57
66
|
Setup a development environment:
|
|
@@ -3,17 +3,17 @@ deltachat_rpc_client/_utils.py,sha256=v0iWVSa6S-s078GgnnhflCRhA9pfWI-CfK8mjZ4zjX
|
|
|
3
3
|
deltachat_rpc_client/account.py,sha256=CNUwmWNdWlaEXuDHy0Xld7EFnNaBrMk_BORkVeNIql4,19549
|
|
4
4
|
deltachat_rpc_client/chat.py,sha256=x5CEIORL1-731QC4KcXd_0JKtRpe7nT9oAygmKkooHI,11707
|
|
5
5
|
deltachat_rpc_client/client.py,sha256=6eP_lH5z7G5Sy7vDRNfKNY3dkUqJqKZDVyCGjynsuW8,7181
|
|
6
|
-
deltachat_rpc_client/const.py,sha256=
|
|
6
|
+
deltachat_rpc_client/const.py,sha256=fnM377RkqOf4rM_jhy-O8dK-MbFLXQYtvprsvVWg2YI,6722
|
|
7
7
|
deltachat_rpc_client/contact.py,sha256=NLh1XNnD_LQf27pNcVgqNN97Gbv190VSCuEyjjce4L4,1893
|
|
8
8
|
deltachat_rpc_client/deltachat.py,sha256=-6SqQAS8_mMWLBP3U1HvFsNIpcAPYBlmqF8R6Bt90YQ,1894
|
|
9
9
|
deltachat_rpc_client/events.py,sha256=Y45LoGlQy0i1U-LhoqF9njqJWA8v4b-XHfXZ4VOr1TQ,10205
|
|
10
10
|
deltachat_rpc_client/message.py,sha256=xA3rLUOPkakqr7kW3JORVYLKHQxvggBqgrXPnDK1a0s,5156
|
|
11
11
|
deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
|
|
12
|
-
deltachat_rpc_client/pytestplugin.py,sha256=
|
|
13
|
-
deltachat_rpc_client/rpc.py,sha256=
|
|
14
|
-
deltachat_rpc_client-2.
|
|
15
|
-
deltachat_rpc_client-2.
|
|
16
|
-
deltachat_rpc_client-2.
|
|
17
|
-
deltachat_rpc_client-2.
|
|
18
|
-
deltachat_rpc_client-2.
|
|
19
|
-
deltachat_rpc_client-2.
|
|
12
|
+
deltachat_rpc_client/pytestplugin.py,sha256=ptQg9BMtNqTmFY3-InFVMRmeRqQBGym7wgdORSaOEk0,10804
|
|
13
|
+
deltachat_rpc_client/rpc.py,sha256=V26Z6rSjwAIWinPft5jnJIQrQg6lnlqLVf9BPWgz6iE,6318
|
|
14
|
+
deltachat_rpc_client-2.31.0.dist-info/licenses/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
|
|
15
|
+
deltachat_rpc_client-2.31.0.dist-info/METADATA,sha256=DjiDz9EP_nYJHuxg1vh_XLtgMI2ZtAuRsiTnwB_eDQQ,2274
|
|
16
|
+
deltachat_rpc_client-2.31.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
deltachat_rpc_client-2.31.0.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
|
|
18
|
+
deltachat_rpc_client-2.31.0.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
|
|
19
|
+
deltachat_rpc_client-2.31.0.dist-info/RECORD,,
|
|
File without changes
|
{deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{deltachat_rpc_client-2.29.0.dist-info → deltachat_rpc_client-2.31.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|