(acfactory, lp)
| 227 | |
| 228 | |
| 229 | def test_forward_messages(acfactory, lp): |
| 230 | ac1, ac2 = acfactory.get_online_accounts(2) |
| 231 | chat = ac1.create_chat(ac2) |
| 232 | |
| 233 | lp.sec("ac1: send message to ac2") |
| 234 | msg_out = chat.send_text("message2") |
| 235 | |
| 236 | lp.sec("ac2: wait for receive") |
| 237 | ev = ac2._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") |
| 238 | msg_in = ac2.get_message_by_id(ev.data2) |
| 239 | assert msg_in.text == "Messages are end-to-end encrypted." |
| 240 | |
| 241 | ev = ac2._evtracker.get_matching("DC_EVENT_INCOMING_MSG|DC_EVENT_MSGS_CHANGED") |
| 242 | assert ev.data2 == msg_out.id |
| 243 | msg_in = ac2.get_message_by_id(msg_out.id) |
| 244 | assert msg_in.text == "message2" |
| 245 | |
| 246 | lp.sec("ac2: check that the message arrived in a chat") |
| 247 | chat2 = msg_in.chat |
| 248 | assert msg_in in chat2.get_messages() |
| 249 | assert not msg_in.is_forwarded() |
| 250 | assert chat2.is_contact_request() |
| 251 | |
| 252 | lp.sec("ac2: create new chat and forward message to it") |
| 253 | chat3 = ac2.create_group_chat("newgroup") |
| 254 | assert not chat3.is_promoted() |
| 255 | ac2.forward_messages([msg_in], chat3) |
| 256 | |
| 257 | lp.sec("ac2: check new chat has a forwarded message") |
| 258 | assert chat3.is_promoted() |
| 259 | messages = chat3.get_messages() |
| 260 | assert len(messages) == 3 |
| 261 | msg = messages[-1] |
| 262 | assert msg.is_forwarded() |
| 263 | ac2.delete_messages(messages) |
| 264 | ev = ac2._evtracker.get_matching("DC_EVENT_MSG_DELETED") |
| 265 | assert ev.data2 == messages[0].id |
| 266 | assert not chat3.get_messages() |
| 267 | |
| 268 | |
| 269 | def test_forward_own_message(acfactory, lp): |
nothing calls this directly
no test coverage detected