Give component instead of stream to Feeder and Sender classes
darcs-hash:20061130215710-86b55-652c6ee7e4a69b67c7502db8db92d3cd0b0000ea.gz
This commit is contained in:
@@ -67,18 +67,18 @@ class FeederComponent(JCLComponent):
|
||||
|
||||
class Feeder(object):
|
||||
"""Abstract feeder class"""
|
||||
def __init__(self, stream = None):
|
||||
self.stream = stream
|
||||
def __init__(self, component = None):
|
||||
self.component = component
|
||||
|
||||
def feed(self, account):
|
||||
def feed(self, _account):
|
||||
"""Feed data for given account"""
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class Sender(object):
|
||||
"""Abstract sender class"""
|
||||
def __init__(self, stream = None):
|
||||
self.stream = stream
|
||||
def __init__(self, component = None):
|
||||
self.component = component
|
||||
|
||||
def send(self, to_account, data):
|
||||
"""Send data to given account"""
|
||||
|
||||
@@ -91,7 +91,7 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
||||
|
||||
class MessageAccountSender(Sender):
|
||||
def send(self, _account, data):
|
||||
self.stream.send(Message(\
|
||||
self.component.stream.send(Message(\
|
||||
from_jid = _account.jid, \
|
||||
to_jid = _account.user_jid, \
|
||||
subject = "Simple Message for account " + _account.name, \
|
||||
@@ -109,8 +109,8 @@ class FeederComponent_TestCase(JCLComponent_TestCase):
|
||||
account2 = Account(user_jid = "user2@test.com", \
|
||||
name = "account2", \
|
||||
jid = "account2@jcl.test.com")
|
||||
self.comp.feeder = AccountFeeder(self.comp.stream)
|
||||
self.comp.sender = MessageAccountSender(self.comp.stream)
|
||||
self.comp.feeder = AccountFeeder(self.comp)
|
||||
self.comp.sender = MessageAccountSender(self.comp)
|
||||
self.comp.handle_tick()
|
||||
|
||||
messages_sent = self.comp.stream.sent
|
||||
|
||||
Reference in New Issue
Block a user