diff options
author | mathieui <mathieui@mathieui.net> | 2021-02-05 19:01:23 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-02-05 20:08:16 +0100 |
commit | 89601289fea2c6f2b47002926eb2609bd72d2a17 (patch) | |
tree | e349f9d4b1f13b57d4df820b8f649c8deee2a726 /itests/test_vcard_avatar.py | |
parent | 6c3f26161e78285696dba0002907529ad73fba72 (diff) | |
download | slixmpp-89601289fea2c6f2b47002926eb2609bd72d2a17.tar.gz slixmpp-89601289fea2c6f2b47002926eb2609bd72d2a17.tar.bz2 slixmpp-89601289fea2c6f2b47002926eb2609bd72d2a17.tar.xz slixmpp-89601289fea2c6f2b47002926eb2609bd72d2a17.zip |
itests: add 0012, 0054, 0084, 0092, 0153, 0191 tests
Diffstat (limited to 'itests/test_vcard_avatar.py')
-rw-r--r-- | itests/test_vcard_avatar.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/itests/test_vcard_avatar.py b/itests/test_vcard_avatar.py new file mode 100644 index 00000000..284c08e1 --- /dev/null +++ b/itests/test_vcard_avatar.py @@ -0,0 +1,49 @@ +import asyncio +import unittest +from slixmpp import JID +from slixmpp.test.integration import SlixIntegration +from hashlib import sha1 + + +class TestVcardAvatar(SlixIntegration): + async def asyncSetUp(self): + await super().asyncSetUp() + self.add_client( + self.envjid('CI_ACCOUNT1'), + self.envstr('CI_ACCOUNT1_PASSWORD'), + ) + self.register_plugins(['xep_0153']) + self.data = b'coucou coucou' + self.hashed_data = sha1(self.data).hexdigest() + await self.connect_clients() + + async def _clear_avatar(self): + """Utility for purging remote state""" + await self.clients[0]['xep_0153'].set_avatar(avatar=b'') + + async def test_set_avatar(self): + """Check we can set and get a PEP avatar and metadata""" + await self._clear_avatar() + + event = self.clients[0].wait_until('vcard_avatar_update') + update = self.clients[0]['xep_0153'].set_avatar( + avatar=self.data + ) + result = await asyncio.gather( + event, + update, + ) + presence = result[0] + hash = presence['vcard_temp_update']['photo'] + self.assertEqual(hash, self.hashed_data) + + iq = await self.clients[0]['xep_0054'].get_vcard( + JID(self.clients[0].boundjid.bare) + ) + photo = iq['vcard_temp']['PHOTO']['BINVAL'] + self.assertEqual(photo, self.data) + + await self._clear_avatar() + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestVcardAvatar) |