summaryrefslogtreecommitdiff
path: root/itests
diff options
context:
space:
mode:
authorLink Mauve <linkmauve@linkmauve.fr>2020-12-07 21:21:43 +0100
committerLink Mauve <linkmauve@linkmauve.fr>2020-12-07 21:21:43 +0100
commitc892fba7785df9f3e1de908c3b9cd4ea06865673 (patch)
treea2cbc4e2b5a227d0fb30350c031b1ead74805da0 /itests
parent340b0f0f169221b31dbcab8d9937b427c55fe2da (diff)
parent758dfb930c9b1f89797a943e4055810386c3acfb (diff)
downloadslixmpp-c892fba7785df9f3e1de908c3b9cd4ea06865673.tar.gz
slixmpp-c892fba7785df9f3e1de908c3b9cd4ea06865673.tar.bz2
slixmpp-c892fba7785df9f3e1de908c3b9cd4ea06865673.tar.xz
slixmpp-c892fba7785df9f3e1de908c3b9cd4ea06865673.zip
Merge branch 'xep-0439-improved' into 'master'
XEP-0439: add events & tests See merge request poezio/slixmpp!82
Diffstat (limited to 'itests')
-rw-r--r--itests/test_quickresponse.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/itests/test_quickresponse.py b/itests/test_quickresponse.py
new file mode 100644
index 00000000..972659f3
--- /dev/null
+++ b/itests/test_quickresponse.py
@@ -0,0 +1,59 @@
+import unittest
+from slixmpp.test.integration import SlixIntegration
+from slixmpp.plugins.xep_0439 import stanza
+
+
+class TestQuickResponse(SlixIntegration):
+ async def asyncSetUp(self):
+ self.add_client(
+ self.envjid('CI_ACCOUNT1'),
+ self.envstr('CI_ACCOUNT1_PASSWORD'),
+ )
+ self.add_client(
+ self.envjid('CI_ACCOUNT2'),
+ self.envstr('CI_ACCOUNT2_PASSWORD'),
+ )
+ self.register_plugins(['xep_0439'])
+ await self.connect_clients()
+
+ async def test_quickresponse(self):
+ """Send and receive actions and responses"""
+ actions = [
+ ('id1', 'Action 1'),
+ ('id2', 'Action 2'),
+ ]
+ self.clients[0]['xep_0439'].ask_for_actions(
+ self.clients[1].boundjid.full,
+ "Action 1 or 2 ?",
+ actions
+ )
+ msg = await self.clients[1].wait_until('action_received')
+ actions_recv = [
+ (st['id'], st['label']) for st in msg if isinstance(st, stanza.Action)
+ ]
+ self.assertEqual(
+ actions,
+ actions_recv,
+ )
+
+ reply = self.clients[1].make_message(
+ mto=self.clients[0].boundjid.full
+ )
+ reply['action_selected']['id'] = 'id1'
+ reply.send()
+
+ reply_recv = await self.clients[0].wait_until('action_selected')
+ self.assertEqual(
+ reply_recv['action_selected']['id'],
+ 'id1',
+ )
+
+ self.clients[0]['xep_0439'].ask_for_response(
+ self.clients[1].boundjid.full,
+ "Reply with action 1 or 2 (id1/id2) ?",
+ actions
+ )
+ msg = await self.clients[1].wait_until('responses_received')
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestQuickResponse)