Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_gui_interface.py « unit « test - dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2055f76531352b3f203833e34e5b71fde093e5ee (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
56
57
'''
Some diverse tests covering functionality in the GUI Interface class.
'''
import unittest

import lib
lib.setup_env()

from gajim.common import logging_helpers
logging_helpers.set_quiet()

from gajim.common import app

from gajim.gui_interface import Interface

from gi.repository import GLib

class TestInterface(unittest.TestCase):

    def test_instantiation(self):
        ''' Test that we can proper initialize and do not fail on globals '''
        def close_app():
            app.app.quit()
        GLib.idle_add(close_app)
        app.app.run()

    def test_links_regexp_entire(self):
        sut = Interface()
        def assert_matches_all(str_):
            m = sut.basic_pattern_re.match(str_)

            # the match should equal the string
            str_span = (0, len(str_))
            self.assertEqual(m.span(), str_span)

        # these entire strings should be parsed as links
        assert_matches_all('http://google.com/')
        assert_matches_all('http://google.com')
        assert_matches_all('http://www.google.ca/search?q=xmpp')

        assert_matches_all('http://tools.ietf.org/html/draft-saintandre-rfc3920bis-05#section-12.3')

        assert_matches_all('http://en.wikipedia.org/wiki/Protocol_(computing)')
        assert_matches_all(
                'http://en.wikipedia.org/wiki/Protocol_%28computing%29')

        assert_matches_all('mailto:test@example.org')

        assert_matches_all('xmpp:example-node@example.com')
        assert_matches_all('xmpp:example-node@example.com/some-resource')
        assert_matches_all('xmpp:example-node@example.com?message')
        assert_matches_all('xmpp://guest@example.com/support@example.com?message')


if __name__ == "__main__":
        #import sys;sys.argv = ['', 'Test.test']
    unittest.main()