This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-slow-tasks' into 'master'
xmlstream: Fix slow tasks See merge request poezio/slixmpp!162
- Loading branch information
Showing
2 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import asyncio | ||
import unittest | ||
from slixmpp.test.integration import SlixIntegration | ||
from slixmpp import Message | ||
|
||
|
||
class TestSlowFilter(SlixIntegration): | ||
async def asyncSetUp(self): | ||
await super().asyncSetUp() | ||
self.add_client( | ||
self.envjid('CI_ACCOUNT1'), | ||
self.envstr('CI_ACCOUNT1_PASSWORD'), | ||
) | ||
self.add_client( | ||
self.envjid('CI_ACCOUNT2'), | ||
self.envstr('CI_ACCOUNT2_PASSWORD'), | ||
) | ||
await self.connect_clients() | ||
|
||
async def test_filters(self): | ||
"""Make sure filters work""" | ||
def add_a(stanza): | ||
if isinstance(stanza, Message): | ||
stanza['body'] = stanza['body'] + ' a' | ||
return stanza | ||
|
||
async def add_b(stanza): | ||
if isinstance(stanza, Message): | ||
stanza['body'] = stanza['body'] + ' b' | ||
return stanza | ||
|
||
async def add_c_wait(stanza): | ||
if isinstance(stanza, Message): | ||
await asyncio.sleep(2) | ||
stanza['body'] = stanza['body'] + ' c' | ||
return stanza | ||
self.clients[0].add_filter('out', add_a) | ||
self.clients[0].add_filter('out', add_b) | ||
self.clients[0].add_filter('out', add_c_wait) | ||
body = 'Msg body' | ||
msg = self.clients[0].make_message( | ||
mto=self.clients[1].boundjid, mbody=body, | ||
) | ||
msg.send() | ||
message = await self.clients[1].wait_until('message') | ||
self.assertEqual(message['body'], body + ' a b c') | ||
|
||
|
||
suite = unittest.TestLoader().loadTestsFromTestCase(TestSlowFilter) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters