From cccc1253aa12f62a6cf8403ee54facf656521504 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 10 Jan 2021 14:38:43 +0100 Subject: XEP-0045: add more elements () --- tests/test_stanza_xep_0045.py | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'tests') diff --git a/tests/test_stanza_xep_0045.py b/tests/test_stanza_xep_0045.py index 29dd75db..707d91cd 100644 --- a/tests/test_stanza_xep_0045.py +++ b/tests/test_stanza_xep_0045.py @@ -13,6 +13,8 @@ from slixmpp.plugins.xep_0045.stanza import ( MUCStatus, MUCInvite, MUCDecline, + MUCUserItem, + MUCActor, ) from slixmpp.xmlstream import register_stanza_plugin, ET @@ -20,6 +22,9 @@ from slixmpp.xmlstream import register_stanza_plugin, ET class TestMUC(SlixTest): def setUp(self): + register_stanza_plugin(MUCPresence, MUCUserItem) + register_stanza_plugin(MUCMessage, MUCUserItem) + register_stanza_plugin(MUCUserItem, MUCActor) register_stanza_plugin(MUCMessage, MUCInvite) register_stanza_plugin(MUCMessage, MUCDecline) register_stanza_plugin(MUCMessage, MUCStatus) @@ -33,7 +38,46 @@ class TestMUC(SlixTest): register_stanza_plugin(MUCOwnerQuery, MUCOwnerDestroy) register_stanza_plugin(MUCAdminQuery, MUCAdminItem, iterable=True) + def testPresence(self): + presence = Presence() + presence['from'] = JID('muc@service/nick') + presence['muc']['item']['affiliation'] = 'member' + presence['muc']['item']['role'] = 'participant' + presence['muc']['status_codes'] = (100, 110, 210) + + self.check(presence, """ + + + + + + + + + """, use_values=False) + + def testPresenceReason(self): + presence = Presence() + presence['from'] = JID('muc@service/nick') + presence['muc']['item']['affiliation'] = 'member' + presence['muc']['item']['role'] = 'participant' + presence['muc']['item']['reason'] = 'coucou' + presence['muc']['item']['actor']['nick'] = 'JPR' + + self.check(presence, """ + + + + + coucou + + + + """, use_values=False) + + + def testPresenceLegacy(self): presence = Presence() presence['from'] = JID('muc@service/nick') presence['muc']['affiliation'] = 'member' @@ -96,5 +140,20 @@ class TestMUC(SlixTest): """, use_values=False) + def testSetAffiliation(self): + iq = Iq() + iq['type'] = 'set' + iq['id'] = '1' + iq['mucadmin_query']['item']['jid'] = JID('test@example.com') + iq['mucadmin_query']['item']['affiliation'] = 'owner' + self.check(iq, """ + + + + + + """, use_values=False) + suite = unittest.TestLoader().loadTestsFromTestCase(TestMUC) -- cgit v1.2.3