Code style cleanup
darcs-hash:20070605190158-86b55-3d4313f040b985814572e0196fac9b4476c3daaf.gz
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -331,7 +331,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
and presence.xpath_eval("@type")[0].get_content() \
|
and presence.xpath_eval("@type")[0].get_content() \
|
||||||
== "unavailable"]), \
|
== "unavailable"]), \
|
||||||
1)
|
1)
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# 'time_handler' tests
|
# 'time_handler' tests
|
||||||
###########################################################################
|
###########################################################################
|
||||||
@@ -423,7 +423,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.comp.account_manager.account_classes = (ExampleAccount, Example2Account)
|
self.comp.account_manager.account_classes = (ExampleAccount, Example2Account)
|
||||||
info_query = Iq(stanza_type = "get", \
|
info_query = Iq(stanza_type = "get", \
|
||||||
from_jid = "user1@test.com", \
|
from_jid = "user1@test.com", \
|
||||||
to_jid = "jcl.test.com")
|
to_jid = "jcl.test.com")
|
||||||
disco_info = self.comp.disco_get_info(None, info_query)
|
disco_info = self.comp.disco_get_info(None, info_query)
|
||||||
self.assertEquals(disco_info.get_identities()[0].get_name(), \
|
self.assertEquals(disco_info.get_identities()[0].get_name(), \
|
||||||
self.comp.name)
|
self.comp.name)
|
||||||
@@ -436,7 +436,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
to_jid = "node_test@jcl.test.com")
|
to_jid = "node_test@jcl.test.com")
|
||||||
disco_info = self.comp.disco_get_info("node_test", info_query)
|
disco_info = self.comp.disco_get_info("node_test", info_query)
|
||||||
self.assertTrue(disco_info.has_feature("jabber:iq:register"))
|
self.assertTrue(disco_info.has_feature("jabber:iq:register"))
|
||||||
|
|
||||||
def test_disco_get_info_long_node(self):
|
def test_disco_get_info_long_node(self):
|
||||||
self.comp.account_manager.account_classes = (ExampleAccount, Example2Account)
|
self.comp.account_manager.account_classes = (ExampleAccount, Example2Account)
|
||||||
info_query = Iq(stanza_type = "get", \
|
info_query = Iq(stanza_type = "get", \
|
||||||
@@ -507,7 +507,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(disco_item.get_name(), "Example2")
|
self.assertEquals(disco_item.get_name(), "Example2")
|
||||||
|
|
||||||
# Be careful, account_classes cannot contains parent classes
|
# Be careful, account_classes cannot contains parent classes
|
||||||
#
|
#
|
||||||
def test_disco_get_items_2types_with_node(self):
|
def test_disco_get_items_2types_with_node(self):
|
||||||
"""get_items on the first account type node. Must return account list of
|
"""get_items on the first account type node. Must return account list of
|
||||||
that type for the current user"""
|
that type for the current user"""
|
||||||
@@ -705,7 +705,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(fields[5].prop("type"), "text-single")
|
self.assertEquals(fields[5].prop("type"), "text-single")
|
||||||
self.assertEquals(fields[5].prop("var"), "test_int")
|
self.assertEquals(fields[5].prop("var"), "test_int")
|
||||||
self.assertEquals(fields[5].prop("label"), "test_int")
|
self.assertEquals(fields[5].prop("label"), "test_int")
|
||||||
|
|
||||||
def test_handle_get_register_new_complex(self):
|
def test_handle_get_register_new_complex(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
@@ -937,7 +937,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(_account.name, "account1")
|
self.assertEquals(_account.name, "account1")
|
||||||
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
stanza_sent = self.comp.stream.sent
|
stanza_sent = self.comp.stream.sent
|
||||||
self.assertEquals(len(stanza_sent), 4)
|
self.assertEquals(len(stanza_sent), 4)
|
||||||
iq_result = stanza_sent[0]
|
iq_result = stanza_sent[0]
|
||||||
@@ -952,7 +952,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
||||||
self.assertEquals(presence_component.get_node().prop("type"), \
|
self.assertEquals(presence_component.get_node().prop("type"), \
|
||||||
"subscribe")
|
"subscribe")
|
||||||
|
|
||||||
message = stanza_sent[2]
|
message = stanza_sent[2]
|
||||||
self.assertTrue(isinstance(message, Message))
|
self.assertTrue(isinstance(message, Message))
|
||||||
self.assertEquals(message.get_from(), "jcl.test.com")
|
self.assertEquals(message.get_from(), "jcl.test.com")
|
||||||
@@ -994,7 +994,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(_account.name, "account1")
|
self.assertEquals(_account.name, "account1")
|
||||||
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
stanza_sent = self.comp.stream.sent
|
stanza_sent = self.comp.stream.sent
|
||||||
self.assertEquals(len(stanza_sent), 4)
|
self.assertEquals(len(stanza_sent), 4)
|
||||||
iq_result = stanza_sent[0]
|
iq_result = stanza_sent[0]
|
||||||
@@ -1009,7 +1009,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
||||||
self.assertEquals(presence_component.get_node().prop("type"), \
|
self.assertEquals(presence_component.get_node().prop("type"), \
|
||||||
"subscribe")
|
"subscribe")
|
||||||
|
|
||||||
message = stanza_sent[2]
|
message = stanza_sent[2]
|
||||||
self.assertTrue(isinstance(message, Message))
|
self.assertTrue(isinstance(message, Message))
|
||||||
self.assertEquals(message.get_from(), "jcl.test.com")
|
self.assertEquals(message.get_from(), "jcl.test.com")
|
||||||
@@ -1071,7 +1071,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(_account.test_enum, "choice3")
|
self.assertEquals(_account.test_enum, "choice3")
|
||||||
self.assertEquals(_account.test_int, 43)
|
self.assertEquals(_account.test_int, 43)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
stanza_sent = self.comp.stream.sent
|
stanza_sent = self.comp.stream.sent
|
||||||
self.assertEquals(len(stanza_sent), 4)
|
self.assertEquals(len(stanza_sent), 4)
|
||||||
iq_result = stanza_sent[0]
|
iq_result = stanza_sent[0]
|
||||||
@@ -1086,7 +1086,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
self.assertEquals(presence_component.get_to(), "user1@test.com")
|
||||||
self.assertEquals(presence_component.get_node().prop("type"), \
|
self.assertEquals(presence_component.get_node().prop("type"), \
|
||||||
"subscribe")
|
"subscribe")
|
||||||
|
|
||||||
message = stanza_sent[2]
|
message = stanza_sent[2]
|
||||||
self.assertTrue(isinstance(message, Message))
|
self.assertTrue(isinstance(message, Message))
|
||||||
self.assertEquals(message.get_from(), "jcl.test.com")
|
self.assertEquals(message.get_from(), "jcl.test.com")
|
||||||
@@ -1101,7 +1101,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(presence_account.get_from(), "account1@jcl.test.com")
|
self.assertEquals(presence_account.get_from(), "account1@jcl.test.com")
|
||||||
self.assertEquals(presence_account.get_to(), "user1@test.com")
|
self.assertEquals(presence_account.get_to(), "user1@test.com")
|
||||||
self.assertEquals(presence_account.get_node().prop("type"), \
|
self.assertEquals(presence_account.get_node().prop("type"), \
|
||||||
"subscribe")
|
"subscribe")
|
||||||
|
|
||||||
def test_handle_set_register_new_default_values(self):
|
def test_handle_set_register_new_default_values(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
@@ -1261,7 +1261,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(_account.test_enum, "choice3")
|
self.assertEquals(_account.test_enum, "choice3")
|
||||||
self.assertEquals(_account.test_int, 43)
|
self.assertEquals(_account.test_int, 43)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
stanza_sent = self.comp.stream.sent
|
stanza_sent = self.comp.stream.sent
|
||||||
self.assertEquals(len(stanza_sent), 2)
|
self.assertEquals(len(stanza_sent), 2)
|
||||||
iq_result = stanza_sent[0]
|
iq_result = stanza_sent[0]
|
||||||
@@ -1312,7 +1312,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(_account.name, "account1")
|
self.assertEquals(_account.name, "account1")
|
||||||
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
self.assertEquals(_account.jid, "account1@jcl.test.com")
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
stanza_sent = self.comp.stream.sent
|
stanza_sent = self.comp.stream.sent
|
||||||
self.assertEquals(len(stanza_sent), 6)
|
self.assertEquals(len(stanza_sent), 6)
|
||||||
presence = stanza_sent[0]
|
presence = stanza_sent[0]
|
||||||
@@ -1345,7 +1345,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEquals(presence.get_node().prop("type"), "unsubscribed")
|
self.assertEquals(presence.get_node().prop("type"), "unsubscribed")
|
||||||
self.assertEquals(presence.get_from(), "jcl.test.com")
|
self.assertEquals(presence.get_from(), "jcl.test.com")
|
||||||
self.assertEquals(presence.get_to(), "user1@test.com")
|
self.assertEquals(presence.get_to(), "user1@test.com")
|
||||||
|
|
||||||
def test_handle_presence_available_to_component(self):
|
def test_handle_presence_available_to_component(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
@@ -1527,7 +1527,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertTrue(isinstance(presence, Presence))
|
self.assertTrue(isinstance(presence, Presence))
|
||||||
self.assertEqual(presence.get_from_jid(), "account11@jcl.test.com")
|
self.assertEqual(presence.get_from_jid(), "account11@jcl.test.com")
|
||||||
self.assertEqual(presence.get_to_jid(), "user1@test.com")
|
self.assertEqual(presence.get_to_jid(), "user1@test.com")
|
||||||
|
|
||||||
def test_handle_presence_available_to_account_live_password_complex(self):
|
def test_handle_presence_available_to_account_live_password_complex(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
@@ -1561,7 +1561,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertTrue(isinstance(presence, Presence))
|
self.assertTrue(isinstance(presence, Presence))
|
||||||
self.assertEqual(presence.get_from_jid(), "account11@jcl.test.com")
|
self.assertEqual(presence.get_from_jid(), "account11@jcl.test.com")
|
||||||
self.assertEqual(presence.get_to_jid(), "user1@test.com")
|
self.assertEqual(presence.get_to_jid(), "user1@test.com")
|
||||||
|
|
||||||
self.assertEqual(unicode(password_message.get_from_jid()), \
|
self.assertEqual(unicode(password_message.get_from_jid()), \
|
||||||
"account11@jcl.test.com")
|
"account11@jcl.test.com")
|
||||||
self.assertEqual(unicode(password_message.get_to_jid()), \
|
self.assertEqual(unicode(password_message.get_to_jid()), \
|
||||||
@@ -1882,7 +1882,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
self.comp.handle_presence_subscribed(None)
|
self.comp.handle_presence_subscribed(None)
|
||||||
self.assertEqual(len(self.comp.stream.sent), 0)
|
self.assertEqual(len(self.comp.stream.sent), 0)
|
||||||
|
|
||||||
def test_handle_presence_unsubscribe_to_account(self):
|
def test_handle_presence_unsubscribe_to_account(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
@@ -2092,7 +2092,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
"Password will be kept during your Jabber session")
|
"Password will be kept during your Jabber session")
|
||||||
self.assertEqual(messages_sent[0].get_body(), \
|
self.assertEqual(messages_sent[0].get_body(), \
|
||||||
"Password will be kept during your Jabber session")
|
"Password will be kept during your Jabber session")
|
||||||
|
|
||||||
def test_handle_tick(self):
|
def test_handle_tick(self):
|
||||||
self.assertRaises(NotImplementedError, self.comp.handle_tick)
|
self.assertRaises(NotImplementedError, self.comp.handle_tick)
|
||||||
|
|
||||||
@@ -2114,7 +2114,7 @@ class JCLComponent_TestCase(unittest.TestCase):
|
|||||||
self.assertEqual(error_sent.get_body(), _account.default_lang_class.error_body \
|
self.assertEqual(error_sent.get_body(), _account.default_lang_class.error_body \
|
||||||
% (exception))
|
% (exception))
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
def test_send_error_second(self):
|
def test_send_error_second(self):
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
|
|||||||
@@ -4,18 +4,18 @@
|
|||||||
## Login : David Rousselie <dax@happycoders.org>
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
## Started on Wed Aug 9 21:34:26 2006 David Rousselie
|
## Started on Wed Aug 9 21:34:26 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
|
||||||
@@ -60,7 +60,7 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
|||||||
ExampleAccount.createTable(ifNotExists = True)
|
ExampleAccount.createTable(ifNotExists = True)
|
||||||
Example2Account.createTable(ifNotExists = True)
|
Example2Account.createTable(ifNotExists = True)
|
||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
Account.dropTable(ifExists = True)
|
Account.dropTable(ifExists = True)
|
||||||
@@ -71,7 +71,7 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
|||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
if os.path.exists(DB_PATH):
|
if os.path.exists(DB_PATH):
|
||||||
os.unlink(DB_PATH)
|
os.unlink(DB_PATH)
|
||||||
|
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
self.comp.time_unit = 1
|
self.comp.time_unit = 1
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
@@ -93,15 +93,15 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
|||||||
# handle_tick is implemented in FeederComponent
|
# handle_tick is implemented in FeederComponent
|
||||||
# so no need to check for NotImplemented raise assertion
|
# so no need to check for NotImplemented raise assertion
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
|
||||||
def test_handle_tick(self):
|
def test_handle_tick(self):
|
||||||
class AccountFeeder(Feeder):
|
class AccountFeeder(Feeder):
|
||||||
def feed(self, _account):
|
def feed(self, _account):
|
||||||
return [("Simple Message for account " + _account.name,
|
return [("Simple Message for account " + _account.name,
|
||||||
"user_jid: " + _account.user_jid), \
|
"user_jid: " + _account.user_jid), \
|
||||||
("Simple Message for account " + _account.name, \
|
("Simple Message for account " + _account.name, \
|
||||||
"jid: " + _account.jid)]
|
"jid: " + _account.jid)]
|
||||||
|
|
||||||
self.comp.stream = MockStream()
|
self.comp.stream = MockStream()
|
||||||
self.comp.stream_class = MockStream
|
self.comp.stream_class = MockStream
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
@@ -158,8 +158,8 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
|||||||
"Simple Message for account account2")
|
"Simple Message for account account2")
|
||||||
self.assertEqual(messages_sent[5].get_body(), \
|
self.assertEqual(messages_sent[5].get_body(), \
|
||||||
"jid: account2@jcl.test.com")
|
"jid: account2@jcl.test.com")
|
||||||
|
|
||||||
class Feeder_TestCase(unittest.TestCase):
|
class Feeder_TestCase(unittest.TestCase):
|
||||||
def test_feed_exist(self):
|
def test_feed_exist(self):
|
||||||
feeder = Feeder()
|
feeder = Feeder()
|
||||||
self.assertRaises(NotImplementedError, feeder.feed, None)
|
self.assertRaises(NotImplementedError, feeder.feed, None)
|
||||||
@@ -183,7 +183,7 @@ class MessageSender_TestCase(unittest.TestCase):
|
|||||||
del account.hub.threadConnection
|
del account.hub.threadConnection
|
||||||
self.sender = MessageSender(self.comp)
|
self.sender = MessageSender(self.comp)
|
||||||
self.message_type = None
|
self.message_type = None
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||||
Account.dropTable(ifExists = True)
|
Account.dropTable(ifExists = True)
|
||||||
|
|||||||
Reference in New Issue
Block a user