test for URL regexp
This commit is contained in:
parent
b490904454
commit
59f9d7dc2e
2 changed files with 50 additions and 0 deletions
47
test/test_misc_interface.py
Normal file
47
test/test_misc_interface.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
# tests for the miscellaneous functions scattered throughout src/gajim.py
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import testlib
|
||||||
|
testlib.setup_env()
|
||||||
|
|
||||||
|
from common import gajim
|
||||||
|
from common import xmpp
|
||||||
|
|
||||||
|
from common.caps import CapsCache
|
||||||
|
|
||||||
|
from mock import Mock
|
||||||
|
|
||||||
|
from gajim import Interface
|
||||||
|
|
||||||
|
gajim.logger = Mock()
|
||||||
|
|
||||||
|
Interface()
|
||||||
|
|
||||||
|
class TestMiscInterface(unittest.TestCase):
|
||||||
|
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()
|
|
@ -30,3 +30,6 @@ def setup_env():
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
||||||
gajim.DATA_DIR = gajim_root + '/data'
|
gajim.DATA_DIR = gajim_root + '/data'
|
||||||
|
|
||||||
|
import gtkgui_helpers
|
||||||
|
gtkgui_helpers.GLADE_DIR = gajim_root + '/data/glade'
|
||||||
|
|
Loading…
Add table
Reference in a new issue