don't set use_stun_server as True by default. It's useless when there is no stun...
[gajim.git] / test / test_pluginmanager.py
blobc6dafac13540161a1230ad94cbdfe818023b364a
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 ## This file is part of Gajim.
5 ##
6 ## Gajim is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published
8 ## by the Free Software Foundation; version 3 only.
9 ##
10 ## Gajim is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
19 '''
20 Testing PluginManager class.
22 :author: Mateusz Biliński <mateusz@bilinski.it>
23 :since: 05/30/2008
24 :copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
25 :license: GPL
26 '''
28 import sys
29 import os
30 import unittest
32 gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
33 sys.path.append(gajim_root + '/src')
35 # a temporary version of ~/.gajim for testing
36 configdir = gajim_root + '/test/tmp'
38 import time
40 # define _ for i18n
41 import __builtin__
42 __builtin__._ = lambda x: x
44 # wipe config directory
45 import os
46 if os.path.isdir(configdir):
47 import shutil
48 shutil.rmtree(configdir)
50 os.mkdir(configdir)
52 import common.configpaths
53 common.configpaths.gajimpaths.init(configdir)
54 common.configpaths.gajimpaths.init_profile()
56 # for some reason common.gajim needs to be imported before xmpppy?
57 from common import gajim
58 from common import xmpp
60 gajim.DATA_DIR = gajim_root + '/data'
62 from common.stanza_session import StanzaSession
64 # name to use for the test account
65 account_name = 'test'
67 from plugins import PluginManager
69 class PluginManagerTestCase(unittest.TestCase):
70 def setUp(self):
71 self.pluginmanager = PluginManager()
73 def tearDown(self):
74 pass
76 def test_01_Singleton(self):
77 """ 1. Checking whether PluginManger class is singleton. """
78 self.pluginmanager.test_arg = 1
79 secondPluginManager = PluginManager()
81 self.failUnlessEqual(id(secondPluginManager), id(self.pluginmanager),
82 'Different IDs in references to PluginManager objects (not a singleton)')
83 self.failUnlessEqual(secondPluginManager.test_arg, 1,
84 'References point to different PluginManager objects (not a singleton')
86 def suite():
87 suite = unittest.TestLoader().loadTestsFromTestCase(PluginManagerTestCase)
88 return suite
90 if __name__=='__main__':
91 runner = unittest.TextTestRunner()
92 test_suite = suite()
93 runner.run(test_suite)