MCPcopy Create free account
hub / github.com/chatmail/core / test_webxdc_message

Function test_webxdc_message

python/tests/test_1_online.py:164–205  ·  view source on GitHub ↗
(acfactory, data, lp)

Source from the content-addressed store, hash-verified

162
163
164def test_webxdc_message(acfactory, data, lp):
165 ac1, ac2 = acfactory.get_online_accounts(2)
166 chat = acfactory.get_accepted_chat(ac1, ac2)
167
168 # Make sure that messages are not immediately auto-deleted on the server:
169 ac2.set_config("bcc_self", "1")
170
171 lp.sec("ac1: prepare and send text message to ac2")
172 msg1 = chat.send_text("message0")
173 assert not msg1.is_webxdc()
174 assert not msg1.send_status_update({"payload": "not an webxdc"}, "invalid")
175 assert not msg1.get_status_updates()
176
177 lp.sec("wait for ac2 to receive message")
178 msg2 = ac2._evtracker.wait_next_incoming_message()
179 assert msg2.text == "message0"
180 assert not msg2.is_webxdc()
181 assert not msg1.get_status_updates()
182
183 lp.sec("ac1: prepare and send webxdc instance to ac2")
184 msg1 = Message.new_empty(ac1, "webxdc")
185 msg1.set_text("message1")
186 msg1.set_file(data.get_path("webxdc/minimal.xdc"))
187 msg1 = chat.send_msg(msg1)
188 assert msg1.is_webxdc()
189 assert msg1.filename
190
191 assert msg1.send_status_update({"payload": "test1"}, "some test data")
192 assert msg1.send_status_update({"payload": "test2"}, "more test data")
193 assert len(msg1.get_status_updates()) == 2
194 update1 = msg1.get_status_updates()[0]
195 assert update1["payload"] == "test1"
196 assert len(msg1.get_status_updates(update1["serial"])) == 1
197
198 lp.sec("wait for ac2 to receive message")
199 msg2 = ac2._evtracker.wait_next_incoming_message()
200 assert msg2.text == "message1"
201 assert msg2.is_webxdc()
202 assert msg2.filename
203 ac2._evtracker.get_info_contains("Marked messages [0-9]+ in folder INBOX as seen.")
204 ac2.direct_imap.select_folder("Inbox")
205 assert len(list(ac2.direct_imap.conn.fetch(AND(seen=True)))) == 1
206
207
208def test_webxdc_huge_update(acfactory, data, lp):

Callers

nothing calls this directly

Calls 15

secMethod · 0.80
is_webxdcMethod · 0.80
send_status_updateMethod · 0.80
get_status_updatesMethod · 0.80
new_emptyMethod · 0.80
set_fileMethod · 0.80
get_online_accountsMethod · 0.45
get_accepted_chatMethod · 0.45
set_configMethod · 0.45
send_textMethod · 0.45
set_textMethod · 0.45

Tested by

no test coverage detected