deltachat-rpc-client 1.157.1__py3-none-any.whl → 1.157.3__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.
@@ -1,8 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
- from pathlib import Path
5
- from tempfile import TemporaryDirectory
6
4
  from typing import TYPE_CHECKING, Optional, Union
7
5
  from warnings import warn
8
6
 
@@ -28,9 +26,12 @@ class Account:
28
26
  def _rpc(self) -> "Rpc":
29
27
  return self.manager.rpc
30
28
 
31
- def wait_for_event(self) -> AttrDict:
29
+ def wait_for_event(self, event_type=None) -> AttrDict:
32
30
  """Wait until the next event and return it."""
33
- return AttrDict(self._rpc.wait_for_event(self.id))
31
+ while True:
32
+ next_event = AttrDict(self._rpc.wait_for_event(self.id))
33
+ if event_type is None or next_event.kind == event_type:
34
+ return next_event
34
35
 
35
36
  def clear_all_events(self):
36
37
  """Removes all queued-up events for a given account. Useful for tests."""
@@ -41,14 +42,14 @@ class Account:
41
42
  self._rpc.remove_account(self.id)
42
43
 
43
44
  def clone(self) -> "Account":
44
- """Clone given account."""
45
- with TemporaryDirectory() as tmp_dir:
46
- tmp_path = Path(tmp_dir)
47
- self.export_backup(tmp_path)
48
- files = list(tmp_path.glob("*.tar"))
49
- new_account = self.manager.add_account()
50
- new_account.import_backup(files[0])
51
- return new_account
45
+ """Clone given account.
46
+ This uses backup-transfer via iroh, i.e. the 'Add second device' feature."""
47
+ future = self._rpc.provide_backup.future(self.id)
48
+ qr = self._rpc.get_backup_qr(self.id)
49
+ new_account = self.manager.add_account()
50
+ new_account._rpc.get_backup(new_account.id, qr)
51
+ future()
52
+ return new_account
52
53
 
53
54
  def start_io(self) -> None:
54
55
  """Start the account I/O."""
@@ -112,10 +113,7 @@ class Account:
112
113
  def bring_online(self):
113
114
  """Start I/O and wait until IMAP becomes IDLE."""
114
115
  self.start_io()
115
- while True:
116
- event = self.wait_for_event()
117
- if event.kind == EventType.IMAP_INBOX_IDLE:
118
- break
116
+ self.wait_for_event(EventType.IMAP_INBOX_IDLE)
119
117
 
120
118
  def create_contact(self, obj: Union[int, str, Contact], name: Optional[str] = None) -> Contact:
121
119
  """Create a new Contact or return an existing one.
@@ -334,24 +332,15 @@ class Account:
334
332
 
335
333
  def wait_for_incoming_msg_event(self):
336
334
  """Wait for incoming message event and return it."""
337
- while True:
338
- event = self.wait_for_event()
339
- if event.kind == EventType.INCOMING_MSG:
340
- return event
335
+ return self.wait_for_event(EventType.INCOMING_MSG)
341
336
 
342
337
  def wait_for_msgs_changed_event(self):
343
338
  """Wait for messages changed event and return it."""
344
- while True:
345
- event = self.wait_for_event()
346
- if event.kind == EventType.MSGS_CHANGED:
347
- return event
339
+ return self.wait_for_event(EventType.MSGS_CHANGED)
348
340
 
349
341
  def wait_for_msgs_noticed_event(self):
350
342
  """Wait for messages noticed event and return it."""
351
- while True:
352
- event = self.wait_for_event()
353
- if event.kind == EventType.MSGS_NOTICED:
354
- return event
343
+ return self.wait_for_event(EventType.MSGS_NOTICED)
355
344
 
356
345
  def wait_for_incoming_msg(self):
357
346
  """Wait for incoming message and return it.
@@ -372,10 +361,7 @@ class Account:
372
361
  break
373
362
 
374
363
  def wait_for_reactions_changed(self):
375
- while True:
376
- event = self.wait_for_event()
377
- if event.kind == EventType.REACTIONS_CHANGED:
378
- return event
364
+ return self.wait_for_event(EventType.REACTIONS_CHANGED)
379
365
 
380
366
  def get_fresh_messages_in_arrival_order(self) -> list[Message]:
381
367
  """Return fresh messages list sorted in the order of their arrival, with ascending IDs."""
@@ -4,6 +4,7 @@ import os
4
4
  import random
5
5
  from typing import AsyncGenerator, Optional
6
6
 
7
+ import py
7
8
  import pytest
8
9
 
9
10
  from . import Account, AttrDict, Bot, Chat, Client, DeltaChat, EventType, Message
@@ -124,3 +125,50 @@ def rpc(tmp_path) -> AsyncGenerator:
124
125
  @pytest.fixture
125
126
  def acfactory(rpc) -> AsyncGenerator:
126
127
  return ACFactory(DeltaChat(rpc))
128
+
129
+
130
+ @pytest.fixture
131
+ def data():
132
+ """Test data."""
133
+
134
+ class Data:
135
+ def __init__(self) -> None:
136
+ for path in reversed(py.path.local(__file__).parts()):
137
+ datadir = path.join("test-data")
138
+ if datadir.isdir():
139
+ self.path = datadir
140
+ return
141
+ raise Exception("Data path cannot be found")
142
+
143
+ def get_path(self, bn):
144
+ """return path of file or None if it doesn't exist."""
145
+ fn = os.path.join(self.path, *bn.split("/"))
146
+ assert os.path.exists(fn)
147
+ return fn
148
+
149
+ def read_path(self, bn, mode="r"):
150
+ fn = self.get_path(bn)
151
+ if fn is not None:
152
+ with open(fn, mode) as f:
153
+ return f.read()
154
+ return None
155
+
156
+ return Data()
157
+
158
+
159
+ @pytest.fixture
160
+ def log():
161
+ """Log printer fixture."""
162
+
163
+ class Printer:
164
+ def section(self, msg: str) -> None:
165
+ print()
166
+ print("=" * 10, msg, "=" * 10)
167
+
168
+ def step(self, msg: str) -> None:
169
+ print("-" * 5, "step " + msg, "-" * 5)
170
+
171
+ def indent(self, msg: str) -> None:
172
+ print(" " + msg)
173
+
174
+ return Printer()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: deltachat-rpc-client
3
- Version: 1.157.1
3
+ Version: 1.157.3
4
4
  Summary: Python client for Delta Chat core JSON-RPC interface
5
5
  Classifier: Development Status :: 5 - Production/Stable
6
6
  Classifier: Intended Audience :: Developers
@@ -1,6 +1,6 @@
1
1
  deltachat_rpc_client/__init__.py,sha256=L19BWnRu9TMF--jQ7e5Asgme951WGsldrTknW86KyTg,566
2
2
  deltachat_rpc_client/_utils.py,sha256=pLOV_pxS2MRreLtq-5rnKJp-BP0m8T4LcbJ8N7Xy-D0,6304
3
- deltachat_rpc_client/account.py,sha256=FGZrM-BdnL6h7P9h1F_svVwYXF94uCm2JmtdjnPR4Lc,15886
3
+ deltachat_rpc_client/account.py,sha256=5RnaXu7iRt0NP-4KxW7s-96vcQkSBfrws3uo9UdV7lM,15575
4
4
  deltachat_rpc_client/chat.py,sha256=1pbuEBWBjZDD9qQ3U1hY5jozzx0MSs9Ybpw33reA2MU,11208
5
5
  deltachat_rpc_client/client.py,sha256=yyXt2USkBeTsqNxtXZNNUqdsPVkqEUHYf7C-5JFmX7s,7043
6
6
  deltachat_rpc_client/const.py,sha256=geXY_H-JHn2HLsYPAAWbwnX5LOksU7zqDZh3AOwmUpg,5577
@@ -9,11 +9,11 @@ deltachat_rpc_client/deltachat.py,sha256=c22_2GX71we6JwQ4yjP-S89mrUYPPbEb3rrPwHH
9
9
  deltachat_rpc_client/events.py,sha256=qYgydsbuWYxQ1PO5ms-D8I5aHpTIiQ6Fg9p23QTvqf0,9877
10
10
  deltachat_rpc_client/message.py,sha256=LVgQTzgaTS-24NPqSLYjgCtyz9PiTPWQgO0c_j9tIs4,3021
11
11
  deltachat_rpc_client/py.typed,sha256=nGQ9Itq-bkXBn5Ri1JIR0oYnDNv7LDRfkowxBSSqVTM,60
12
- deltachat_rpc_client/pytestplugin.py,sha256=zRRxsSBvzpbRUxSmKjd7EKZbosAb60Ew53Yu5W7W4Nc,4055
12
+ deltachat_rpc_client/pytestplugin.py,sha256=d12M2CPPbv1nHu9oMd4KSCi9Rd8QWAaJKkOmc3v0fGY,5272
13
13
  deltachat_rpc_client/rpc.py,sha256=7RIdyEDwOXU0ACU0LanVqTT1RuIDci5iDr7dNEDE_tE,6554
14
- deltachat_rpc_client-1.157.1.dist-info/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
- deltachat_rpc_client-1.157.1.dist-info/METADATA,sha256=xfneJEioraZngBSBu7iBVo9Oqh1EGOa_VY6zyTZZPRQ,2153
16
- deltachat_rpc_client-1.157.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
17
- deltachat_rpc_client-1.157.1.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
- deltachat_rpc_client-1.157.1.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
- deltachat_rpc_client-1.157.1.dist-info/RECORD,,
14
+ deltachat_rpc_client-1.157.3.dist-info/LICENSE,sha256=Pz2eACSxkhsGfW9_iN60pgy-enjnbGTj8df8O3ebnQQ,16726
15
+ deltachat_rpc_client-1.157.3.dist-info/METADATA,sha256=-SpxGqSwZNzCGUAte7DDzFEI_5FH1XaKy7P0sTiOpuo,2153
16
+ deltachat_rpc_client-1.157.3.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
17
+ deltachat_rpc_client-1.157.3.dist-info/entry_points.txt,sha256=VHpX6EnKBaNj89qJWctApThnMa8suyaamfZEnQacXgc,81
18
+ deltachat_rpc_client-1.157.3.dist-info/top_level.txt,sha256=ePNMkY10htGrLiLydH1ITvYFM3LcTEa51HyPqJ40hDk,21
19
+ deltachat_rpc_client-1.157.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5