summaryrefslogtreecommitdiff
path: root/tests/test_stanza_xep_0461.py
blob: b95504812a536fe147431ffc3dab74505243aca2 (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
import unittest
from slixmpp import Message
from slixmpp.test import SlixTest
from slixmpp.plugins.xep_0461 import stanza


class TestReply(SlixTest):
    def setUp(self):
        stanza.register_plugins()

    def testReply(self):
        message = Message()
        message["reply"]["id"] = "some-id"
        message["body"] = "some-body"

        self.check(
            message,
            """
            <message>
              <reply xmlns="urn:xmpp:reply:0" id="some-id" />
              <body>some-body</body>
            </message>
            """,
        )

    def testFallback(self):
        message = Message()
        message["body"] = "12345\nrealbody"
        message["feature_fallback"]["for"] = "NS"
        message["feature_fallback"]["fallback_body"]["start"] = "0"
        message["feature_fallback"]["fallback_body"]["end"] = "6"

        self.check(
            message,
            """
            <message xmlns="jabber:client">
              <body>12345\nrealbody</body>
              <fallback xmlns='urn:xmpp:feature-fallback:0' for='NS'>
                <body start="0" end="6" />
              </fallback>
            </message>
            """,
        )

        assert message["feature_fallback"].get_stripped_body() == "realbody"


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