diff options
author | Link Mauve <linkmauve@linkmauve.fr> | 2021-02-13 20:25:57 +0100 |
---|---|---|
committer | Link Mauve <linkmauve@linkmauve.fr> | 2021-02-13 20:25:57 +0100 |
commit | f50dfd6644aa004ae0c6cad41cf131273bc49663 (patch) | |
tree | de932679a63d2d377842d579fe5d48696c23013b /itests/test_pep.py | |
parent | ace82c9bc47df97344952e71cd59ee99114abbb0 (diff) | |
parent | bbcc977d1d87b564f766cf973de078884d3be845 (diff) | |
download | slixmpp-f50dfd6644aa004ae0c6cad41cf131273bc49663.tar.gz slixmpp-f50dfd6644aa004ae0c6cad41cf131273bc49663.tar.bz2 slixmpp-f50dfd6644aa004ae0c6cad41cf131273bc49663.tar.xz slixmpp-f50dfd6644aa004ae0c6cad41cf131273bc49663.zip |
Merge branch 'remove-more-extra-args' into 'master'
More cleanup of extra args, types, docs, and API
See merge request poezio/slixmpp!126
Diffstat (limited to 'itests/test_pep.py')
-rw-r--r-- | itests/test_pep.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/itests/test_pep.py b/itests/test_pep.py new file mode 100644 index 00000000..a674a348 --- /dev/null +++ b/itests/test_pep.py @@ -0,0 +1,64 @@ +import asyncio +import unittest +from uuid import uuid4 +from slixmpp.exceptions import IqError +from slixmpp.test.integration import SlixIntegration +from slixmpp.xmlstream import ElementBase, register_stanza_plugin +from slixmpp.plugins.xep_0060.stanza import Item + +class Mystanza(ElementBase): + namespace = 'random-ns' + name = 'mystanza' + plugin_attrib = 'mystanza' + interfaces = {'test'} + +register_stanza_plugin(Item, Mystanza) + +class TestPEP(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'), + ) + self.register_plugins(['xep_0222', 'xep_0223']) + for client in self.clients: + client.auto_authorize = True + await self.connect_clients() + + async def test_pep_public(self): + """Check we can get and set public PEP data""" + stanza = Mystanza() + stanza['test'] = str(uuid4().hex) + await self.clients[0]['xep_0222'].store(stanza, id='toto') + fetched = await self.clients[0]['xep_0222'].retrieve( + stanza.namespace, + ) + fetched_stanza = fetched['pubsub']['items']['item']['mystanza'] + self.assertEqual(fetched_stanza['test'], stanza['test']) + + async def test_pep_private(self): + """Check we can get and set private PEP data""" + stanza = Mystanza() + stanza['test'] = str(uuid4().hex) + await self.clients[0]['xep_0223'].store( + stanza, node='private-random', id='toto' + ) + fetched = await self.clients[0]['xep_0223'].retrieve( + 'private-random', + ) + fetched_stanza = fetched['pubsub']['items']['item']['mystanza'] + self.assertEqual(fetched_stanza['test'], stanza['test']) + + with self.assertRaises(IqError): + fetched = await self.clients[1]['xep_0060'].get_item( + jid=self.clients[0].boundjid.bare, + node='private-random', + item_id='toto', + ) + +suite = unittest.TestLoader().loadTestsFromTestCase(TestPEP) |