summaryrefslogtreecommitdiff
path: root/itests/test_user_avatar.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-02-05 20:14:41 +0100
committermathieui <mathieui@mathieui.net>2021-02-05 20:14:41 +0100
commitcff4588499d74e392cab646a46217f069cb1ef01 (patch)
treee349f9d4b1f13b57d4df820b8f649c8deee2a726 /itests/test_user_avatar.py
parentc82e1a4039dbf5d24990d28d665ba973fc9c9de7 (diff)
parent89601289fea2c6f2b47002926eb2609bd72d2a17 (diff)
downloadslixmpp-cff4588499d74e392cab646a46217f069cb1ef01.tar.gz
slixmpp-cff4588499d74e392cab646a46217f069cb1ef01.tar.bz2
slixmpp-cff4588499d74e392cab646a46217f069cb1ef01.tar.xz
slixmpp-cff4588499d74e392cab646a46217f069cb1ef01.zip
Merge branch 'updat-typing-and-generic-args' into 'master'
Update typing and generic args for plugins (step 1) See merge request poezio/slixmpp!120
Diffstat (limited to 'itests/test_user_avatar.py')
-rw-r--r--itests/test_user_avatar.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/itests/test_user_avatar.py b/itests/test_user_avatar.py
new file mode 100644
index 00000000..193bbe72
--- /dev/null
+++ b/itests/test_user_avatar.py
@@ -0,0 +1,61 @@
+import asyncio
+import unittest
+from slixmpp import JID
+from slixmpp.test.integration import SlixIntegration
+
+
+class TestUserAvatar(SlixIntegration):
+ async def asyncSetUp(self):
+ await super().asyncSetUp()
+ self.add_client(
+ self.envjid('CI_ACCOUNT1'),
+ self.envstr('CI_ACCOUNT1_PASSWORD'),
+ )
+ self.register_plugins(['xep_0084'])
+ self.data = b'coucou coucou'
+ await self.connect_clients()
+
+ async def _clear_avatar(self):
+ """Utility for purging remote state"""
+ await self.clients[0]['xep_0084'].stop()
+ await self.clients[0]['xep_0084'].publish_avatar(b'')
+
+ async def test_set_avatar(self):
+ """Check we can set and get a PEP avatar and metadata"""
+ await self._clear_avatar()
+
+ await self.clients[0]['xep_0084'].publish_avatar(
+ self.data
+ )
+ metadata = {
+ 'id': self.clients[0]['xep_0084'].generate_id(self.data),
+ 'bytes': 13,
+ 'type': 'image/jpeg',
+ }
+ # Wait for metadata publish event
+ event = self.clients[0].wait_until('avatar_metadata_publish')
+ publish = self.clients[0]['xep_0084'].publish_avatar_metadata(
+ metadata,
+ )
+ res = await asyncio.gather(
+ event,
+ publish,
+ )
+ message = res[0]
+ recv_meta = message['pubsub_event']['items']['item']['avatar_metadata']
+ info = recv_meta['info']
+ self.assertEqual(info['bytes'], metadata['bytes'])
+ self.assertEqual(info['type'], metadata['type'])
+ self.assertEqual(info['id'], metadata['id'])
+
+ recv = await self.clients[0]['xep_0084'].retrieve_avatar(
+ JID(self.clients[0].boundjid.bare),
+ info['id']
+ )
+ avatar = recv['pubsub']['items']['item']['avatar_data']['value']
+ self.assertEqual(avatar, self.data)
+
+ await self._clear_avatar()
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestUserAvatar)