summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0425.py
blob: 96d979e8163cb587acd5d86c2ef85d4600eafd1e (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
import unittest
from slixmpp import Message, Iq, JID
from slixmpp.test import SlixTest
from slixmpp.plugins.xep_0425 import stanza


class TestModeration(SlixTest):

    def setUp(self):
        stanza.register_plugins()

    def testModerate(self):
        iq = Iq()
        iq['type'] = 'set'
        iq['id'] = 'a'
        iq['apply_to']['id'] = 'some-id'
        iq['apply_to']['moderate'].enable('retract')
        iq['apply_to']['moderate']['reason'] = 'R'

        self.check(iq, """
<iq type='set' id='a'>
  <apply-to id="some-id" xmlns="urn:xmpp:fasten:0">
    <moderate xmlns='urn:xmpp:message-moderate:0'>
      <retract xmlns='urn:xmpp:message-retract:0'/>
      <reason>R</reason>
    </moderate>
  </apply-to>
</iq>
        """, use_values=False)

    def testModerated(self):
        message = Message()
        message['moderated']['by'] = JID('toto@titi')
        message['moderated']['retracted']['stamp'] = '2019-09-20T23:09:32Z'
        message['moderated']['reason'] = 'R'

        self.check(message, """
<message>
  <moderated xmlns="urn:xmpp:message-moderate:0" by="toto@titi">
    <retracted stamp="2019-09-20T23:09:32Z" xmlns="urn:xmpp:message-retract:0" />
    <reason>R</reason>
  </moderated>
</message>
        """)


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