2 # -*- coding: utf-8 -*-
4 ## This file is part of Gajim.
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.
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/>.
20 Testing PluginManager class.
22 :author: Mateusz Biliński <mateusz@bilinski.it>
24 :copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
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'
42 __builtin__
._ = lambda x
: x
44 # wipe config directory
46 if os
.path
.isdir(configdir
):
48 shutil
.rmtree(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
67 from plugins
import PluginManager
69 class PluginManagerTestCase(unittest
.TestCase
):
71 self
.pluginmanager
= PluginManager()
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')
87 suite
= unittest
.TestLoader().loadTestsFromTestCase(PluginManagerTestCase
)
90 if __name__
=='__main__':
91 runner
= unittest
.TextTestRunner()
93 runner
.run(test_suite
)