summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0405.py
blob: 5d834cf1a0e889de053a3c050a5a851605d5586a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import unittest
from slixmpp import Iq, Message, JID
from slixmpp.test import SlixTest
from slixmpp.plugins.xep_0405 import stanza
from slixmpp.plugins.xep_0369 import stanza as mstanza
from slixmpp.plugins.xep_0405.mix_pam import BASE_NODES


class TestMIXPAMStanza(SlixTest):

    def setUp(self):
        stanza.register_plugins()
        mstanza.register_plugins()

    def testMIXPAMJoin(self):
        """Test that data is converted to base64"""
        iq = Iq()
        iq['type'] = 'set'
        iq['client_join']['channel'] = JID('mix@example.com')
        for node in BASE_NODES:
            sub = mstanza.Subscribe()
            sub['node'] = node
            iq['client_join']['mix_join'].append(sub)
        iq['client_join']['mix_join']['nick'] = 'Toto'

        self.check(iq, """
          <iq type="set">
              <client-join xmlns='urn:xmpp:mix:pam:2' channel='mix@example.com'>
                  <join xmlns='urn:xmpp:mix:core:1'>
                      <subscribe node='urn:xmpp:mix:nodes:messages'/>
                      <subscribe node='urn:xmpp:mix:nodes:participants'/>
                      <subscribe node='urn:xmpp:mix:nodes:info'/>
                      <nick>Toto</nick>
                  </join>
              </client-join>
          </iq>
        """)


    def testMIXPAMLeave(self):
        iq = Iq()
        iq['type'] = 'set'
        iq['client_leave']['channel'] = JID('mix@example.com')
        iq['client_leave'].enable('mix_leave')

        self.check(iq, """
          <iq type="set">
              <client-leave xmlns='urn:xmpp:mix:pam:2' channel='mix@example.com'>
                  <leave xmlns='urn:xmpp:mix:core:1'/>
              </client-leave>
          </iq>
        """)


suite = unittest.TestLoader().loadTestsFromTestCase(TestMIXPAMStanza)