2008-06-02 01:33:51 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published
|
|
|
|
## by the Free Software Foundation; version 3 only.
|
|
|
|
##
|
|
|
|
## Gajim is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
|
|
|
'''
|
|
|
|
Testing PluginManager class.
|
|
|
|
|
|
|
|
:author: Mateusz Biliński <mateusz@bilinski.it>
|
|
|
|
:since: 05/30/2008
|
|
|
|
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
|
|
|
|
:license: GPL
|
|
|
|
'''
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
|
2017-06-20 23:07:28 +02:00
|
|
|
sys.path.append(gajim_root + '/gajim')
|
2008-06-02 01:33:51 +02:00
|
|
|
|
2008-06-03 01:15:08 +02:00
|
|
|
# a temporary version of ~/.gajim for testing
|
|
|
|
configdir = gajim_root + '/test/tmp'
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
# define _ for i18n
|
2017-09-10 12:22:49 +02:00
|
|
|
import builtins
|
|
|
|
builtins._ = lambda x: x
|
2008-06-03 01:15:08 +02:00
|
|
|
|
|
|
|
# wipe config directory
|
|
|
|
import os
|
|
|
|
if os.path.isdir(configdir):
|
2010-04-08 01:20:17 +02:00
|
|
|
import shutil
|
|
|
|
shutil.rmtree(configdir)
|
2008-06-03 01:15:08 +02:00
|
|
|
|
|
|
|
os.mkdir(configdir)
|
|
|
|
|
2017-06-13 23:58:06 +02:00
|
|
|
import gajim.common.configpaths
|
|
|
|
gajim.common.configpaths.gajimpaths.init(configdir)
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2017-08-13 13:18:56 +02:00
|
|
|
# for some reason common.app needs to be imported before xmpppy?
|
|
|
|
from gajim.common import app
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2017-09-16 12:18:22 +02:00
|
|
|
app.DATA_DIR = gajim_root + '/gajim/data'
|
2008-06-03 01:15:08 +02:00
|
|
|
|
|
|
|
from common.stanza_session import StanzaSession
|
|
|
|
|
|
|
|
# name to use for the test account
|
|
|
|
account_name = 'test'
|
|
|
|
|
2008-06-02 01:33:51 +02:00
|
|
|
from plugins import PluginManager
|
|
|
|
|
|
|
|
class PluginManagerTestCase(unittest.TestCase):
|
2010-04-08 01:20:17 +02:00
|
|
|
def setUp(self):
|
|
|
|
self.pluginmanager = PluginManager()
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2010-04-08 01:20:17 +02:00
|
|
|
def tearDown(self):
|
|
|
|
pass
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2010-04-08 01:20:17 +02:00
|
|
|
def test_01_Singleton(self):
|
|
|
|
""" 1. Checking whether PluginManger class is singleton. """
|
|
|
|
self.pluginmanager.test_arg = 1
|
|
|
|
secondPluginManager = PluginManager()
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2017-09-10 12:21:10 +02:00
|
|
|
self.assertEqual(id(secondPluginManager), id(self.pluginmanager),
|
|
|
|
'Different IDs in references to PluginManager objects (not a singleton)')
|
|
|
|
self.assertEqual(secondPluginManager.test_arg, 1,
|
|
|
|
'References point to different PluginManager objects (not a singleton')
|
2008-06-03 01:15:08 +02:00
|
|
|
|
2008-06-02 01:33:51 +02:00
|
|
|
def suite():
|
2010-04-08 01:20:17 +02:00
|
|
|
suite = unittest.TestLoader().loadTestsFromTestCase(PluginManagerTestCase)
|
|
|
|
return suite
|
2008-06-02 01:33:51 +02:00
|
|
|
|
|
|
|
if __name__=='__main__':
|
2010-04-08 01:20:17 +02:00
|
|
|
runner = unittest.TextTestRunner()
|
|
|
|
test_suite = suite()
|
|
|
|
runner.run(test_suite)
|