예제 #1
0
import unittest

import time

import lib
lib.setup_env()

from gi.repository import GLib

from gajim.common import resolver

from mock import Mock, expectParams
from gajim_mocks import *
from xmpp_mocks import IdleQueueThread

NONSENSE_NAME = 'sfsdfsdfsdf.sdfs.fsd'
JABBERCZ_TXT_NAME = '_xmppconnect.jabber.cz'
JABBERCZ_SRV_NAME = '_xmpp-client._tcp.jabber.cz'

TEST_LIST = [(NONSENSE_NAME, 'srv', False), (JABBERCZ_SRV_NAME, 'srv', True)]


class TestResolver(unittest.TestCase):
    '''
    Test for LibAsyncNSResolver and NSLookupResolver. Requires working
    network connection.
    '''
    def setUp(self):
        self.idlequeue_thread = IdleQueueThread()
        self.idlequeue_thread.start()
        self.main_context = GLib.MainContext()
예제 #2
0
# tests for the miscellaneous functions scattered throughout src/gajim.py
import unittest

import lib
lib.setup_env()

from common import gajim
from gajim import Interface

from mocks import *
gajim.logger = MockLogger()

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')