Correct threads tests
darcs-hash:20080519201548-86b55-448f18676bd232a91e598c9d25c34576af854b69.gz
This commit is contained in:
@@ -4,18 +4,18 @@
|
|||||||
## Login : David Rousselie <dax@happycoders.org>
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
## Started on Wed Aug 9 21:04:42 2006 David Rousselie
|
## Started on Wed Aug 9 21:04:42 2006 David Rousselie
|
||||||
## $Id$
|
## $Id$
|
||||||
##
|
##
|
||||||
## Copyright (C) 2006 David Rousselie
|
## Copyright (C) 2006 David Rousselie
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
## the Free Software Foundation; either version 2 of the License, or
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
## (at your option) any later version.
|
## (at your option) any later version.
|
||||||
##
|
##
|
||||||
## This program is distributed in the hope that it will be useful,
|
## This program is distributed in the hope that it will be useful,
|
||||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program; if not, write to the Free Software
|
## along with this program; if not, write to the Free Software
|
||||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
@@ -70,13 +70,13 @@ class FeederComponent(JCLComponent):
|
|||||||
self.check_interval = 1
|
self.check_interval = 1
|
||||||
|
|
||||||
self.__logger = logging.getLogger("jcl.jabber.FeederComponent")
|
self.__logger = logging.getLogger("jcl.jabber.FeederComponent")
|
||||||
|
|
||||||
def handle_tick(self):
|
def handle_tick(self):
|
||||||
"""Implement main feed/send behavior"""
|
"""Implement main feed/send behavior"""
|
||||||
model.db_connect()
|
model.db_connect()
|
||||||
self.handler.handle(\
|
self.handler.handle(\
|
||||||
None, self.lang.get_default_lang_class(),
|
None, self.lang.get_default_lang_class(),
|
||||||
self.handler.filter(None,
|
self.handler.filter(None,
|
||||||
self.lang.get_default_lang_class()))
|
self.lang.get_default_lang_class()))
|
||||||
model.db_disconnect()
|
model.db_disconnect()
|
||||||
|
|
||||||
@@ -160,4 +160,3 @@ class FeederHandler(Handler):
|
|||||||
for data in self.feeder.feed(_account):
|
for data in self.feeder.feed(_account):
|
||||||
self.sender.send(_account, data)
|
self.sender.send(_account, data)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@@ -3017,7 +3017,7 @@ class JCLCommandManagerRestartCommand_TestCase(JCLCommandManagerTestCase):
|
|||||||
self.assertTrue(self.comp.running)
|
self.assertTrue(self.comp.running)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 2)
|
self.assertEquals(len(threads), 2)
|
||||||
threading.Event().wait(1)
|
threading.Event().wait(2)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 1)
|
self.assertEquals(len(threads), 1)
|
||||||
self.assertTrue(self.comp.restart)
|
self.assertTrue(self.comp.restart)
|
||||||
@@ -3068,7 +3068,7 @@ class JCLCommandManagerRestartCommand_TestCase(JCLCommandManagerTestCase):
|
|||||||
self.assertTrue(self.comp.running)
|
self.assertTrue(self.comp.running)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 2)
|
self.assertEquals(len(threads), 2)
|
||||||
threading.Event().wait(1)
|
threading.Event().wait(2)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 1)
|
self.assertEquals(len(threads), 1)
|
||||||
self.assertTrue(self.comp.restart)
|
self.assertTrue(self.comp.restart)
|
||||||
@@ -3166,7 +3166,7 @@ class JCLCommandManagerShutdownCommand_TestCase(JCLCommandManagerTestCase):
|
|||||||
self.assertTrue(self.comp.running)
|
self.assertTrue(self.comp.running)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 2)
|
self.assertEquals(len(threads), 2)
|
||||||
threading.Event().wait(1)
|
threading.Event().wait(2)
|
||||||
threads = threading.enumerate()
|
threads = threading.enumerate()
|
||||||
self.assertEquals(len(threads), 1)
|
self.assertEquals(len(threads), 1)
|
||||||
self.assertFalse(self.comp.restart)
|
self.assertFalse(self.comp.restart)
|
||||||
|
|||||||
@@ -3175,13 +3175,15 @@ class AccountManager_TestCase(JCLTestCase):
|
|||||||
|
|
||||||
def test_cancel_account_error(self):
|
def test_cancel_account_error(self):
|
||||||
"""Test Account error reset"""
|
"""Test Account error reset"""
|
||||||
|
self.comp.stream = MockStream()
|
||||||
|
self.comp.stream_class = MockStream
|
||||||
_account = Account(user=User(jid="user1@test.com"),
|
_account = Account(user=User(jid="user1@test.com"),
|
||||||
name="account11",
|
name="account11",
|
||||||
jid="account11@jcl.test.com")
|
jid="account11@jcl.test.com")
|
||||||
_account.error = "test exception"
|
_account.error = "test exception"
|
||||||
result = self.account_manager.cancel_account_error(_account)
|
self.account_manager.cancel_account_error(_account)
|
||||||
self.assertEquals(len(result), 1)
|
self.assertEquals(len(self.comp.stream.sent), 1)
|
||||||
presence = result[0].xmlnode
|
presence = self.comp.stream.sent[0].xmlnode
|
||||||
self.assertEquals(presence.name, "presence")
|
self.assertEquals(presence.name, "presence")
|
||||||
self.assertEquals(presence.prop("type"), None)
|
self.assertEquals(presence.prop("type"), None)
|
||||||
self.assertEquals(presence.prop("from"), _account.jid)
|
self.assertEquals(presence.prop("from"), _account.jid)
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ def get_all_accounts_count(account_class=Account, filter=None):
|
|||||||
else:
|
else:
|
||||||
accounts_count = account_class.select(filter).count()
|
accounts_count = account_class.select(filter).count()
|
||||||
return accounts_count
|
return accounts_count
|
||||||
|
|
||||||
class PresenceAccount(Account):
|
class PresenceAccount(Account):
|
||||||
DO_NOTHING = 0
|
DO_NOTHING = 0
|
||||||
DO_SOMETHING = 1
|
DO_SOMETHING = 1
|
||||||
@@ -387,4 +387,3 @@ class LegacyJID(InheritableSQLObject):
|
|||||||
legacy_address = StringCol()
|
legacy_address = StringCol()
|
||||||
jid = StringCol()
|
jid = StringCol()
|
||||||
account = ForeignKey('Account')
|
account = ForeignKey('Account')
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class JCLRunner(object):
|
|||||||
("o", "log-stdout", None,
|
("o", "log-stdout", None,
|
||||||
"\t\t\t\t\tLog on stdout",
|
"\t\t\t\t\tLog on stdout",
|
||||||
lambda arg: self.set_attr("log_stdout", True)),
|
lambda arg: self.set_attr("log_stdout", True)),
|
||||||
("f", "log-file", "component",
|
("f:", "log-file=", "component",
|
||||||
"\t\t\t\t\tLog in file",
|
"\t\t\t\t\tLog in file",
|
||||||
lambda arg: self.set_attr("log_file", arg)),
|
lambda arg: self.set_attr("log_file", arg)),
|
||||||
("h", "help", None,
|
("h", "help", None,
|
||||||
|
|||||||
Reference in New Issue
Block a user