summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0045.py
diff options
context:
space:
mode:
authorLink Mauve <linkmauve@linkmauve.fr>2021-01-10 15:12:20 +0100
committerLink Mauve <linkmauve@linkmauve.fr>2021-01-10 15:12:20 +0100
commitca465032e7438476ca87a1299b6ce00db322bd85 (patch)
tree2de5603a84bcaf0c848074ed8a3db3155d769c53 /tests/test_stanza_xep_0045.py
parentfb31e9c1fd47370ffec796d29f81264a9d8f197e (diff)
parent6369ee0e5f3d7835f19471d75a914e8da3cfc126 (diff)
downloadslixmpp-ca465032e7438476ca87a1299b6ce00db322bd85.tar.gz
slixmpp-ca465032e7438476ca87a1299b6ce00db322bd85.tar.bz2
slixmpp-ca465032e7438476ca87a1299b6ce00db322bd85.tar.xz
slixmpp-ca465032e7438476ca87a1299b6ce00db322bd85.zip
Merge branch 'xep-0045-fixes-misc' into 'master'
Misc fixes for XEP-0045 See merge request poezio/slixmpp!97
Diffstat (limited to 'tests/test_stanza_xep_0045.py')
-rw-r--r--tests/test_stanza_xep_0045.py59
1 files changed, 59 insertions, 0 deletions
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,9 +38,48 @@ 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, """
+<presence from='muc@service/nick'>
+ <x xmlns='http://jabber.org/protocol/muc#user'>
+ <item affiliation='member' role='participant'/>
+ <status code='100'/>
+ <status code='110'/>
+ <status code='210'/>
+ </x>
+</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, """
+<presence from='muc@service/nick'>
+ <x xmlns='http://jabber.org/protocol/muc#user'>
+ <item affiliation='member' role='participant'>
+ <actor nick="JPR"/>
+ <reason>coucou</reason>
+ </item>
+ </x>
+</presence>
+ """, use_values=False)
+
+
+ def testPresenceLegacy(self):
+ presence = Presence()
+ presence['from'] = JID('muc@service/nick')
presence['muc']['affiliation'] = 'member'
presence['muc']['role'] = 'participant'
presence['muc']['status_codes'] = (100, 110, 210)
@@ -96,5 +140,20 @@ class TestMUC(SlixTest):
</iq>
""", 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, """
+<iq type='set' id='1'>
+ <query xmlns='http://jabber.org/protocol/muc#admin'>
+ <item jid='test@example.com'
+ affiliation='owner'/>
+ </query>
+</iq>
+ """, use_values=False)
+
suite = unittest.TestLoader().loadTestsFromTestCase(TestMUC)