File: test_restricted_reactions.py

package info (click to toggle)
python-nbxmpp 6.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,360 kB
  • sloc: python: 20,137; makefile: 4
file content (95 lines) | stat: -rw-r--r-- 3,906 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import unittest

from nbxmpp.modules.discovery import parse_disco_info
from nbxmpp.protocol import Iq


class RestrictedReactions(unittest.TestCase):
    def test_form_present(self):
        node = """
        <iq from='benvolio@capulet.lit/230193' id='disco1' to='juliet@capulet.lit/chamber' type='result'>
          <query xmlns='http://jabber.org/protocol/disco#info' node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>
            <identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/>
            <identity xml:lang='el' category='client' name='Ψ 0.11' type='pc'/>
            <feature var='http://jabber.org/protocol/caps'/>
            <feature var='http://jabber.org/protocol/disco#info'/>
            <feature var='http://jabber.org/protocol/disco#items'/>
            <feature var='http://jabber.org/protocol/muc'/>
            <x xmlns='jabber:x:data' type='result'>
              <field var='FORM_TYPE' type='hidden'>
                <value>urn:xmpp:dataforms:softwareinfo</value>
              </field>
              <field var='ip_version'>
                <value>ipv4</value>
                <value>ipv6</value>
              </field>
              <field var='os'>
                <value>Mac</value>
              </field>
              <field var='os_version'>
                <value>10.5.1</value>
              </field>
              <field var='software'>
                <value>Psi</value>
              </field>
              <field var='software_version'>
                <value>0.11</value>
              </field>
            </x>
            <x xmlns='jabber:x:data' type='result'>
              <field var='FORM_TYPE' type='hidden'>
                <value>urn:xmpp:reactions:0:restrictions</value>
              </field>
              <field var='max_reactions_per_user'>
                <value>1</value>
              </field>
              <field var='allowlist' type='list-multi'>
                <value>💘</value>
                <value>❤️</value>
                <value>💜</value>
              </field>
            </x>
          </query>
        </iq>"""

        info = parse_disco_info(Iq(node=node))
        self.assertEqual(info.reactions_per_user, 1)
        self.assertEqual(info.reactions_allowlist, ["💘", "❤️", "💜"])

    def test_form_absent(self):
        node = """
        <iq from='benvolio@capulet.lit/230193' id='disco1' to='juliet@capulet.lit/chamber' type='result'>
          <query xmlns='http://jabber.org/protocol/disco#info' node='http://psi-im.org#q07IKJEyjvHSyhy//CH0CxmKi8w='>
            <identity xml:lang='en' category='client' name='Psi 0.11' type='pc'/>
            <identity xml:lang='el' category='client' name='Ψ 0.11' type='pc'/>
            <feature var='http://jabber.org/protocol/caps'/>
            <feature var='http://jabber.org/protocol/disco#info'/>
            <feature var='http://jabber.org/protocol/disco#items'/>
            <feature var='http://jabber.org/protocol/muc'/>
            <x xmlns='jabber:x:data' type='result'>
              <field var='FORM_TYPE' type='hidden'>
                <value>urn:xmpp:dataforms:softwareinfo</value>
              </field>
              <field var='ip_version'>
                <value>ipv4</value>
                <value>ipv6</value>
              </field>
              <field var='os'>
                <value>Mac</value>
              </field>
              <field var='os_version'>
                <value>10.5.1</value>
              </field>
              <field var='software'>
                <value>Psi</value>
              </field>
              <field var='software_version'>
                <value>0.11</value>
              </field>
            </x>
          </query>
        </iq>"""

        info = parse_disco_info(Iq(node=node))
        self.assertIsNone(info.reactions_per_user)
        self.assertIsNone(info.reactions_allowlist)