Correct threads tests

darcs-hash:20080519201548-86b55-448f18676bd232a91e598c9d25c34576af854b69.gz
This commit is contained in:
David Rousselie
2008-05-19 22:15:48 +02:00
parent 2ea561c9cc
commit 3d286c3efe
5 changed files with 16 additions and 16 deletions

View File

@@ -4,18 +4,18 @@
## Login : David Rousselie <dax@happycoders.org>
## Started on Wed Aug 9 21:04:42 2006 David Rousselie
## $Id$
##
##
## Copyright (C) 2006 David Rousselie
## This program 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; either version 2 of the License, or
## (at your option) any later version.
##
##
## This program 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 this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@@ -70,13 +70,13 @@ class FeederComponent(JCLComponent):
self.check_interval = 1
self.__logger = logging.getLogger("jcl.jabber.FeederComponent")
def handle_tick(self):
"""Implement main feed/send behavior"""
model.db_connect()
self.handler.handle(\
None, self.lang.get_default_lang_class(),
self.handler.filter(None,
None, self.lang.get_default_lang_class(),
self.handler.filter(None,
self.lang.get_default_lang_class()))
model.db_disconnect()
@@ -160,4 +160,3 @@ class FeederHandler(Handler):
for data in self.feeder.feed(_account):
self.sender.send(_account, data)
return []

View File

@@ -3017,7 +3017,7 @@ class JCLCommandManagerRestartCommand_TestCase(JCLCommandManagerTestCase):
self.assertTrue(self.comp.running)
threads = threading.enumerate()
self.assertEquals(len(threads), 2)
threading.Event().wait(1)
threading.Event().wait(2)
threads = threading.enumerate()
self.assertEquals(len(threads), 1)
self.assertTrue(self.comp.restart)
@@ -3068,7 +3068,7 @@ class JCLCommandManagerRestartCommand_TestCase(JCLCommandManagerTestCase):
self.assertTrue(self.comp.running)
threads = threading.enumerate()
self.assertEquals(len(threads), 2)
threading.Event().wait(1)
threading.Event().wait(2)
threads = threading.enumerate()
self.assertEquals(len(threads), 1)
self.assertTrue(self.comp.restart)
@@ -3166,7 +3166,7 @@ class JCLCommandManagerShutdownCommand_TestCase(JCLCommandManagerTestCase):
self.assertTrue(self.comp.running)
threads = threading.enumerate()
self.assertEquals(len(threads), 2)
threading.Event().wait(1)
threading.Event().wait(2)
threads = threading.enumerate()
self.assertEquals(len(threads), 1)
self.assertFalse(self.comp.restart)

View File

@@ -3175,13 +3175,15 @@ class AccountManager_TestCase(JCLTestCase):
def test_cancel_account_error(self):
"""Test Account error reset"""
self.comp.stream = MockStream()
self.comp.stream_class = MockStream
_account = Account(user=User(jid="user1@test.com"),
name="account11",
jid="account11@jcl.test.com")
_account.error = "test exception"
result = self.account_manager.cancel_account_error(_account)
self.assertEquals(len(result), 1)
presence = result[0].xmlnode
self.account_manager.cancel_account_error(_account)
self.assertEquals(len(self.comp.stream.sent), 1)
presence = self.comp.stream.sent[0].xmlnode
self.assertEquals(presence.name, "presence")
self.assertEquals(presence.prop("type"), None)
self.assertEquals(presence.prop("from"), _account.jid)

View File

@@ -247,7 +247,7 @@ def get_all_accounts_count(account_class=Account, filter=None):
else:
accounts_count = account_class.select(filter).count()
return accounts_count
class PresenceAccount(Account):
DO_NOTHING = 0
DO_SOMETHING = 1
@@ -387,4 +387,3 @@ class LegacyJID(InheritableSQLObject):
legacy_address = StringCol()
jid = StringCol()
account = ForeignKey('Account')

View File

@@ -86,7 +86,7 @@ class JCLRunner(object):
("o", "log-stdout", None,
"\t\t\t\t\tLog on stdout",
lambda arg: self.set_attr("log_stdout", True)),
("f", "log-file", "component",
("f:", "log-file=", "component",
"\t\t\t\t\tLog in file",
lambda arg: self.set_attr("log_file", arg)),
("h", "help", None,