Complete FeederComponent tests

- raise NotImplementedError exception for abstracts methods
- implement test_handle_tick

darcs-hash:20061105195847-86b55-af88958079cd5321808c2540d8c498bf47f60999.gz
This commit is contained in:
David Rousselie
2006-11-05 20:58:47 +01:00
parent 5c1804f484
commit b2fca94692
6 changed files with 125 additions and 56 deletions

View File

@@ -460,7 +460,7 @@ class JCLComponent(Component, object):
self.account_class.q.user_jid == base_from_jid
and self.account_class.q.name == name)
if accounts.count() >= 1:
self._send_presence_available(_account[0], show, lang_class)
self._send_presence_available(accounts[0], show, lang_class)
self.db_disconnect()
return 1

30
src/jcl/jabber/error.py Normal file
View File

@@ -0,0 +1,30 @@
##
## error.py
## Login : David Rousselie <dax@happycoders.org>
## Started on Sun Nov 5 20:13:48 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
##
"""Jabber exception classes"""
__revision__ = "$Id: error.py,v 1.1 2006/11/05 20:13:48 dax Exp $"
class FieldError(Exception):
"""Error raised when error exists on Jabber Data Form fields"""
pass

View File

@@ -53,36 +53,34 @@ class FeederComponent(JCLComponent):
self.sender = Sender()
self.check_interval = 1
self.__logger = logging.getLogger("jcl.jabber.JCLComponent")
self.__logger = logging.getLogger("jcl.jabber.FeederComponent")
def handle_tick(self):
"""Implement main feed/send behavior"""
pass
self.db_connect()
for acc in self.account_class.select():
print "OK"
# for data in self.feeder.feed(account):
# self.sender.send(account, data)
for _account in self.account_class.select(orderBy = "user_jid"):
for data in self.feeder.feed(_account):
self.sender.send(_account, data)
self.db_disconnect()
class Feeder(object):
"""Abstract feeder class"""
def __init__(self):
pass
def __init__(self, stream = None):
self.stream = stream
def feed(self, account):
"""Feed data for given account"""
pass
raise NotImplementedError
class Sender(object):
"""Abstract sender class"""
def __init__(self):
pass
def __init__(self, stream = None):
self.stream = stream
def send(self, to_account, data):
"""Send data to given account"""
pass
raise NotImplementedError