gajim-plural/test/test_misc_interface.py

46 lines
1.3 KiB
Python
Raw Normal View History

2008-06-29 07:25:59 +02:00
# tests for the miscellaneous functions scattered throughout src/gajim.py
import unittest
import lib
lib.setup_env()
2008-06-29 07:25:59 +02:00
from common import gajim
from gajim import Interface
2008-08-09 01:53:44 +02:00
from mocks import MockLogger
gajim.logger = MockLogger()
2008-06-29 07:25:59 +02:00
Interface()
class TestMiscInterface(unittest.TestCase):
2008-06-29 07:25:59 +02:00
def test_links_regexp_entire(self):
def assert_matches_all(str):
m = gajim.interface.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__':
unittest.main()
# vim: se ts=3: