summaryrefslogtreecommitdiff
path: root/tests/test_jid.py
blob: 38dc6ed5c51a0fdd736c6f3f6d73ad169d2a801b (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
from sleekxmpp.test import *
from sleekxmpp.xmlstream.jid import JID


class TestJIDClass(SleekTest):

    """Verify that the JID class can parse and manipulate JIDs."""

    def testJIDfromfull(self):
        """Test using JID of the form 'user@server/resource/with/slashes'."""
        self.check_JID(JID('user@someserver/some/resource'),
                       'user',
                       'someserver',
                       'some/resource',
                       'user@someserver',
                       'user@someserver/some/resource',
                       'user@someserver/some/resource')

    def testJIDchange(self):
        """Test changing JID of the form 'user@server/resource/with/slashes'"""
        j = JID('user1@someserver1/some1/resource1')
        j.user = 'user'
        j.domain = 'someserver'
        j.resource = 'some/resource'
        self.check_JID(j,
                       'user',
                       'someserver',
                       'some/resource',
                       'user@someserver',
                       'user@someserver/some/resource',
                       'user@someserver/some/resource')

    def testJIDnoresource(self):
        """Test using JID of the form 'user@domain'."""
        self.check_JID(JID('user@someserver'),
                       'user',
                       'someserver',
                       '',
                       'user@someserver',
                       'user@someserver',
                       'user@someserver')

    def testJIDnouser(self):
        """Test JID of the form 'component.domain.tld'."""
        self.check_JID(JID('component.someserver'),
                       '',
                       'component.someserver',
                       '',
                       'component.someserver',
                       'component.someserver',
                       'component.someserver')


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